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

Automatically use execinfo for crash handler on *BSD and musl-based Linux #63983

Merged
merged 1 commit into from
Oct 5, 2022

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 6, 2022

This closes #57193 and closes godotengine/godot-proposals#2439.

Tested on an Alpine Linux container (docker run -itv $PWD:/opt/godot alpine in a Godot repository clone, then install dependencies), it works as expected.

Unlike my glibc-based desktop, I get a crash on startup when running the project manager with --headless:

/opt/godot # bin/godot.linuxbsd.tools.64 --headless
Godot Engine v4.0.alpha.custom_build.e06a61b25 - https://godotengine.org

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha.custom_build (e06a61b25877003aa53d5617d48012b93adb5ebd) 

Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
-- END OF BACKTRACE --
================================================================
Aborted (core dumped)

--version works though:

/opt/godot # bin/godot.linuxbsd.tools.64 --version
4.0.alpha.custom_build.e06a61b25

@akien-mga
Copy link
Member

I'd suggest instead:

diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 00e2b9e6eb..8c1b3cbfb6 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -382,7 +382,10 @@ def configure(env):
     if platform.system() == "Linux":
         env.Append(LIBS=["dl"])
 
-    if platform.system().find("BSD") >= 0:
+    if not env["execinfo"] and platform.libc_ver()[0] != "glibc":
+        # The default crash handler depends on glibc, so if the host uses
+        # a different libc (BSD libc, musl), fall back to libexecinfo.
+        print("Note: Using `execinfo=yes` for the crash handler as required on platforms where glibc is missing.")
         env["execinfo"] = True
 
     if env["execinfo"]:

Apparently CPython's platform.libc_ver() doesn't identify musl properly python/cpython#87414, but it returns a tuple of empty strings so this logic would work anyway as we only care to know that we're not running glibc.

A drawback to both proposed changes is that it might prevent cross-compiling for Linux-glibc from a BSD (existing issue) or musl (new issue) system. But that's very niche, we can address it if/when someone wants to do this (e.g. by making execinfo=<auto|yes|no>).

@Calinou Calinou changed the title Automatically use execinfo for crash handler on musl-based Linux Automatically use execinfo for crash handler on *BSD and musl-based Linux Oct 3, 2022
@Calinou
Copy link
Member Author

Calinou commented Oct 3, 2022

@akien-mga I applied your suggestion and tested it locally, works well 🙂

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from last comment, should be good to merge.

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 5, 2022
@akien-mga akien-mga merged commit 2c94470 into godotengine:master Oct 5, 2022
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.6.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 30, 2022
@Calinou Calinou deleted the scons-linux-execinfo-musl branch February 9, 2023 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants