From a83af3c69a3cd6da5ba21ea5062205fa664e59d2 Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Wed, 27 Apr 2011 17:55:13 -0400 Subject: [PATCH] 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 --- luabind/typeid.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/luabind/typeid.hpp b/luabind/typeid.hpp index e1a2f335..2484c21b 100644 --- a/luabind/typeid.hpp +++ b/luabind/typeid.hpp @@ -6,6 +6,7 @@ # define LUABIND_TYPEID_081227_HPP # include +# include # include # include @@ -33,17 +34,17 @@ class type_id bool operator!=(type_id const& other) const { - return *id != *other.id; + return std::strcmp(id->name(), other.id->name()) != 0; } bool operator==(type_id const& other) const { - return *id == *other.id; + return std::strcmp(id->name(), other.id->name()) == 0; } bool operator<(type_id const& other) const { - return id->before(*other.id); + return std::strcmp(id->name(), other.id->name()) < 0; } char const* name() const