godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.21k stars 21.04k forks source link

Official Godot Linux binary crashes if GDNative plugin use Boost.Serialization #44987

Open o01eg opened 3 years ago

o01eg commented 3 years ago

Godot version: 3.2.3 from downloads

OS/device including version: Ubuntu 18.04; Devuan Testing

Issue description:

When I call function in GDNative plugin which calls Boost.Serialization I suddenly get to some Godot exception handler:

(gdb) l
116 // preserve correct static polymorphism.
117 class BOOST_SYMBOL_VISIBLE xml_oarchive :
118     public xml_oarchive_impl<xml_oarchive>
119 {
120 public:
121     xml_oarchive(std::ostream & os, unsigned int flags = 0) :
122         xml_oarchive_impl<xml_oarchive>(os, flags)
123     {
124         if(0 == (flags & no_header))
125             init();
(gdb) p no_header
$5 = boost::archive::no_header
(gdb) n
125             init();
(gdb) s

Thread 1 "Godot_v3.2.3-st" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f78ca6dc921 in __GI_abort () at abort.c:79
#2  0x00007f78ba778b15 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#3  0x00007f78baa202ba in __gxx_personality_v0 () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00000000028fc7ab in _Unwind_RaiseException_Phase2 ()
#5  0x0000000000000000 in ?? ()

It doesn't crash if I build Godot 3.2.3 from sources.

Steps to reproduce:

  1. Download repo for https://github.com/freeorion/freeorion/pull/3255
  2. Build cmake project: cmake -DBUILD_CLIENT_GG=OFF -DBUILD_CLIENT_GODOT=ON
  3. Place Godot binary to the same folder with freeoriond.
  4. Kill any leftover freeoriond processes. 5.1. Start project from <freeorion sources>/godot/client. Press Quickstart button. 5.2. Or call headless test <freeorion sources>/godot/client $ <freeoriond binaries folder>/godot.x11.opt.tools.64 --verbose -d -s --path $PWD addons/gut/gut_cmdln.gd -gtest=res://test/integration/quickstart.gd -gexit

Minimal reproduction project:

https://github.com/freeorion/freeorion/pull/3255 I'll try to prepare a minimal project later:

akien-mga commented 3 years ago

Official binaries are built with these non-default options, you can try them locally to see if either of them triggers the issue, or if it's something else:

They're built on Ubuntu 14.04 with GCC 9.3.0.

o01eg commented 3 years ago

I've tried scons platform=x11 use_lto=yes use_static_cpp=yes target=release tools=no and it doesn't crash.

o01eg commented 3 years ago

Looks like it somehow catch https://github.com/boostorg/serialization/issues/122

fire commented 3 years ago

🎉 Sounds like this issue is resolved.

o01eg commented 3 years ago

No, it doesn't crash for Godot built from sources. I didn't enable sanitizers to crash on it either.

akien-mga commented 3 years ago

If there's UB in Boost there's not much we can do.

In your local builds it probably works because you're building both Godot, Boost and your GDNative code with the same toolchains (glibc, compiler, libstdc++, linker).

Official Godot builds are built against a much older glibc yet with a likely newer compiler than what you have on Ubuntu 18.04. I'm not an expert on ABI compatibility but this looks like a situation where it can't be guaranteed with a behemoth like Boost which is as big as the libstdc++ itself.

So I'm not sure there's anything we can fix. Maybe @hpvb or @vnen would know more about why this can happen and if we can fix it.