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

cross compiled binaries segfault on pthread_cancel(3) due to missing libgcc_s.so #240484

Closed
ghost opened this issue Jun 29, 2023 · 1 comment · Fixed by #238154
Closed

cross compiled binaries segfault on pthread_cancel(3) due to missing libgcc_s.so #240484

ghost opened this issue Jun 29, 2023 · 1 comment · Fixed by #238154

Comments

@ghost
Copy link

ghost commented Jun 29, 2023

This is entirely my fault. 😢

The problem

Any binary using our pkgsCross.*.glibc built after #209870 but before #238154 which attempts to use pthread_cancel(3) will (deliberately) segfault.

Since there is no error message and because pthread_cancel(3) is a somewhat-obscure API this is extremely frustrating to troubleshoot.

The reason for the problem

The cross compiler we were using to build glibc between those two commits didn't have a libgcc_s.so. So when glibc attempts to dlopen() libgcc_s.so, it can't find it. The glibc developers believe that segfaulting without an error message is the right thing to do in this situation.

Additional details

Our cross compilers don't (currently) bootstrap using the normal stdenv stages.

The "first stage" gcc (crossStageStatic for cross), doesn't produce a libgcc_s.so since it is a "static only" compiler. This compiler is used to compile glibc. Because libgcc_s.so doesn't exist when glibc is built, pkgsCross.*.glibc.stdenv.cc.cc.libgcc doesn't exist. So user-defined-trusted-dirs isn't added to Makeflags and glibc doesn't know where to look for libgcc_s.so. Also, cross-compiled glibcs won't pull libgcc into their closure like they should.

This is fixed by:

#238154

@ghost
Copy link
Author

ghost commented Jun 29, 2023

Example of the problem:

$ nix-instantiate . -A pkgsCross.aarch64-multiplatform.glibc.passthru.libgcc
error: attribute 'libgcc' in selection path 'pkgsCross.aarch64-multiplatform.glibc.passthru.libgcc' not found

@ghost ghost mentioned this issue Jun 30, 2023
4 tasks
@ghost ghost changed the title cross compiled binaries cannot find libgcc_s.so cross compiled binaries segfault on pthread_cancel(3) due to missing libgcc_s.so Jun 30, 2023
@ghost ghost closed this as completed in #238154 Jul 12, 2023
This issue was closed.
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.

0 participants