-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault when creating instance of a third-party class that has the name of a godot class but that is not in a namespace. #82812
Comments
Thanks for the report! I may be seeing similar behavior in one of my extensions. I created a If I put my This is really, really strange behavior. It's as if the dynamic linker is deciding to link the I'm also on Linux (Ubuntu 22.04). I think the default behavior on Linux is to export all symbol, and I wonder if it's treating the Godot binary like an .so that's exporting all classes? I haven't had a chance to try this, but I wonder if we compiled Godot with |
I did a little bit more research, and we could also try passing
|
That last idea seems to fix it in my testing! (I didn't try the first idea, since that seemed like more work. ;-)) I created PR #82973 with the change @ariesssss Can you try building Godot with that PR, and see if that fixes the problem for you? |
Thanks for your work. I'm not exactly sure where you want me to make the change to the call to
and a source with
When I then export the project, it hangs, it does not even output the first line:
You are definitely on to something, because if I remove the constructor, then the export works fine. But I'm not convinced that this will fix my issue, because in my case the symbols are different. With
for my
for |
It's the change to the Godot engine from this PR #82973 - you can apply the patch from there and recompile Godot, or you can download the build artifacts from CI (I just added some instructions to the PR description explaining how to do that).
I'm hopeful that it'll fix the issue (it fixes a similar issue for me), but only testing will say for sure! |
You win, with your change it works! However, something very strange is going on. It is as if godot is searching for a constructor of I still think it is better to figure out what exactly goes wrong here. If not, the issue will undoubtedly come back to haunt us somewhere in the future. Just my 2 cents ... |
I just realised that in my case compiled code for the |
Awesome, thanks for testing!
Yep! It's still weird to me, that the dynamic linker would mess with symbols that are defined - in my mental model of how it works, it only links undefined symbols, but I guess we learned something new. :-) |
I'm by no means an expert on dynamic linkers. But the gdextension library, opened by the |
Upon re-reading the explanation for
This makes me think that it is actually the other way round (from what I assumed up to now, anyway): not my I now do think that it is a bit unfortunate that the godot editor code is, by and large, not in a namespace. |
Godot version
v4.1.1.stable.custom_build [bd6af8e]
System information
Godot v4.1.1.stable (bd6af8e) - Linux Mint 21.2 (Victoria) - Vulkan (Forward+) - integrated Intel(R) Graphics (RPL-P) () - 13th Gen Intel(R) Core(TM) i7-1360P (16 Threads)
Issue description
I'm working on a gdextension. It builds on other libraries that I have made a long time ago. One of those other libraries contains a class called
Object
. It is not declared in a namespace.If in my C++ gdextension I declare a
static ::Object * object {new ::Object {}};
then the godot editor, when opening a project that uses my gdextension, crashes immediately, typically withmalloc(): unaligned tcache chunk
. Also exporting the project from the command line fails.Also other no-namespace classes with a name of a class in the godot namespace, like
::Node
,::Node3D
, and::CSGPolygon3D
, cause segmentation faults. The class::Vector3
is okay, however.This issue was discusses at 36627-object-class-in-library.
Steps to reproduce
Start with for example the gdextension example from the godot docs. Add a header file
Object.h
likeclass Object { static Object * const object; };
and a source file
Object.cpp
like::Object * const ::Object::object {new ::Object {}};
Build the gdextension, open the project in the editor, the editor should crash.
Minimal reproduction project
I hope that the description of the steps to reproduce suffice.
The text was updated successfully, but these errors were encountered: