Open vilarion opened 3 years ago
Hi, this looks indeed like a bug, and the warning about optimizing overflow could be related. If you can a segfaulting test executable with gdb and post a stack trace, that might be helpful.
Hi, I added -ggdb3 for more helpful output:
Starting program: /home/andreas/src/luabind/build/test/test_null_pointer
Program received signal SIGSEGV, Segmentation fault.
0x0000555555563e4d in luabind::detail::object_rep::object_rep (this=0x555555589608, instance=0x0, crep_=0x5555555884b8) at /usr/include/boost/type_traits/aligned_storage.hpp:108
108 aligned_storage()
(gdb) bt
#0 0x0000555555563e4d in luabind::detail::object_rep::object_rep (this=0x555555589608, instance=0x0, crep_=0x5555555884b8) at /usr/include/boost/type_traits/aligned_storage.hpp:108
#1 0x0000555555564244 in luabind::detail::push_new_instance (L=L@entry=0x55555557ff70, cls=cls@entry=0x5555555884b8) at /usr/include/c++/8/new:169
#2 0x0000555555560d3a in luabind::detail::class_rep::constructor_dispatcher (L=0x55555557ff70) at /home/andreas/src/luabind/src/class_rep.cpp:124
#3 0x00007ffff7d8cc75 in ?? () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#4 0x00007ffff7d98825 in ?? () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#5 0x00007ffff7d8cf9e in ?? () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#6 0x00007ffff7d8c5cf in ?? () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#7 0x00007ffff7d8d201 in ?? () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#8 0x00007ffff7d890a1 in lua_pcallk () from /lib/x86_64-linux-gnu/liblua5.2.so.0
#9 0x000055555555e521 in dostring (state=state@entry=0x55555557ff70, str=str@entry=0x5555555661f8 "a = A()\ne = a:f()\nassert(e == nil)") at /home/andreas/src/luabind/test/main.cpp:103
#10 0x000055555555e17c in test_main (L=0x55555557ff70) at /home/andreas/src/luabind/test/test_null_pointer.cpp:60
#11 0x000055555555c31a in main () at /home/andreas/src/luabind/test/main.cpp:128
Hi all, turns out I have the same issue with gcc 7.5 on Ubuntu. I tracked this down to the instance_buffer
in object_ref.hpp
.
Looks like the use of boost::aligned_storage
did something funky. Took a while to track down, but I made the following workaround patch and it started working:
diff --git a/luabind/detail/object_rep.hpp b/luabind/detail/object_rep.hpp
index 07272e6..16dda05 100644
--- a/luabind/detail/object_rep.hpp
+++ b/luabind/detail/object_rep.hpp
@@ -98,7 +98,8 @@ namespace luabind { namespace detail
void operator=(object_rep const&);
BOOST_STATIC_CONSTANT(std::size_t, instance_buffer_size=32);
- boost::aligned_storage<instance_buffer_size> m_instance_buffer;
+ // boost::aligned_storage<instance_buffer_size> m_instance_buffer;
+ char m_instance_buffer[instance_buffer_size];
instance_holder* m_instance;
class_rep* m_classrep; // the class information about this object's type
std::size_t m_dependency_cnt; // counts dependencies
Obviously boost::aligned_storage
is useful, but this got me forward a step in integrating a modernized luabind.
When configuring with
cmake -DCMAKE_BUILD_TYPE=Release ../luabind
40 tests segfault after building. We are using GCC 8.3.Here is the complete log: https://pastebin.com/6pjHeygA
I tried it with a clang 12 snapshot, where everything works just fine. Also everything works fine with a non-release build using GCC 8.3. Maybe I am missing something?