Skip to content
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

GDExtension libraries that use std::call_once during static initialization crash Godot editor with freetype, libpng, zlib, graphite, harfbuzz as system-provided #91401

Open
j20001970 opened this issue May 1, 2024 · 5 comments · May be fixed by #99883

Comments

@j20001970
Copy link
Contributor

j20001970 commented May 1, 2024

Tested versions

Reproducible in recent Godot 4.x version (latest attempt is v4.4.dev.custom_build [893bbdf]) that uses system-provided freetype, libpng, zlib, graphite, harfbuzz libraries.

System information

Godot v4.4.dev (893bbdf) - Freedesktop SDK 24.08 (Flatpak runtime) on Wayland - Wayland display driver, Single-window, 1 monitor - Vulkan (Forward+) - dedicated AMD Radeon RX 6650 XT (RADV NAVI23) - 12th Gen Intel(R) Core(TM) i5-12500 (12 threads)

The problem is found when developing GDExtension libraries on Linux, not sure if it also occur on other platforms.

Issue description

If Godot editor is using system-provided freetype, libpng, zlib, graphite, harfbuzz libraries instead of built-in, opening projects with GDExtension libraries that uses std::call_once during static initialization will crash the editor.

While official Godot editor will work without problems as it has everything builtin, many custom builds including Linux distribution packages (for example Arch and Flathub) configure Godot to use these libraries as system-provided, resulting in said GDExtension libraries unusable in custom Godot editor builds.

However, building icu4c libraries as system-provided like freetype, libpng, zlib, graphite, harfbuzz seems to solve the problem, I suppose this can be fixed by including builtin_icu4c into ft_linked_deps check in linuxbsd detect.py.

Steps to reproduce

  1. Clone the MRP project.
  2. Build example GDExtension library with scons.
  3. Open the project with Godot editor that has every libraries builtin.
  4. The project opens successfully, once called appear on stdout.
  5. Build Godot editor with builtin_freetype=no builtin_libpng=no builtin_zlib=no builtin_graphite=no builtin_harfbuzz=no, and open the project.
  6. Editor crashed with signal 11.
  7. Build Godot editor again with builtin_freetype=no builtin_libpng=no builtin_zlib=no builtin_graphite=no builtin_harfbuzz=no builtin_icu4c=no
  8. The project opens successfully.

Minimal reproduction project (MRP)

https://github.com/j20001970/godot_static_call_once_crash

@j20001970
Copy link
Contributor Author

After some investigation of the issue, I think I managed to narrow down the problem for a bit, and the bug report has been updated.

Honestly I do not know if this is Godot-side or Protobuf-side problem, and is way beyond my skill.

@j20001970 j20001970 changed the title GDExtension plugin crash Godot editor that use certain module as system-provided GDExtension libraries that use std::call_once during static initialization crash Godot editor with freetype, libpng, zlib, graphite, harfbuzz as system-provided Sep 29, 2024
@j20001970
Copy link
Contributor Author

Update: I've once again narrow down the problem, and maybe found the actual root cause for real this time.

I'm curious that does Godot team receive notification when bug report is updated?

@Zireael07
Copy link
Contributor

@j20001970 Everyone who watches the repository receives notification when someone comments.

@j20001970
Copy link
Contributor Author

I think this issue is related to GDExtension though it has no topic:gdextension label, can you please update the label so this issue can have better visibility? Thank you.

@j20001970 j20001970 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
@j20001970
Copy link
Contributor Author

Reopened due to new finding and a potential fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants