Skip to content

Commit a83af3c

Browse files
Peter ColbergOberon00
Peter Colberg
authored andcommitted
Fix use of Luabind classes across shared library boundary.
Classes registered with Luabind are only valid within that shared library, but cause segmentation faults if used across shared library boundaries. Compare types using typeid(T).name() instead of typeid(T)::operator=. This fixes use of shared libraries with the GCC 3.0 C++ ABI and loaded using Lua's require(), which does not pass RTLD_GLOBAL to dlopen. http://gcc.gnu.org/faq.html#dso The typeid problem has appeared in other C++ libraries, e.g. boost::any. https://svn.boost.org/trac/boost/ticket/754 https://svn.boost.org/trac/boost/changeset/56168
1 parent 950e1e3 commit a83af3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

luabind/typeid.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# define LUABIND_TYPEID_081227_HPP
77

88
# include <boost/operators.hpp>
9+
# include <cstring>
910
# include <typeinfo>
1011
# include <luabind/detail/primitives.hpp>
1112

@@ -33,17 +34,17 @@ class type_id
3334

3435
bool operator!=(type_id const& other) const
3536
{
36-
return *id != *other.id;
37+
return std::strcmp(id->name(), other.id->name()) != 0;
3738
}
3839

3940
bool operator==(type_id const& other) const
4041
{
41-
return *id == *other.id;
42+
return std::strcmp(id->name(), other.id->name()) == 0;
4243
}
4344

4445
bool operator<(type_id const& other) const
4546
{
46-
return id->before(*other.id);
47+
return std::strcmp(id->name(), other.id->name()) < 0;
4748
}
4849

4950
char const* name() const

0 commit comments

Comments
 (0)