-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/link: unknown symbol __stack_chk_fail_local on Alpine Linux i386 #58385
Comments
Thanks for the report. I'll take a look.
If this is the case, I am wondering why we aren't seeing similar failures on our existing Alpine amd64 builder? |
This only happens on i386 as only on i386 (and 32-bit ppc) GCC emits local calls to
|
Change https://go.dev/cl/466936 mentions this issue: |
Change https://go.dev/cl/466935 mentions this issue: |
Add -fno-stack-protector back to the default set of CFLAGS for cgo, so as to avoid problems with internal linking locating the library containing the "__stack_chk_fail_local" support function that some compilers emit (the specific archive can vary based on GOOS). Updates #52919. Updates #54313. Updates #57261. Updates #58385. Change-Id: I4591bfb15501f04b7afe1fcd50c4fb93c86db63d Reviewed-on: https://go-review.googlesource.com/c/go/+/466935 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Add -fno-stack-protector back to the default set of CFLAGS for cgo, so as to avoid problems with internal linking locating the library containing the "__stack_chk_fail_local" support function that some compilers emit (the specific archive can vary based on GOOS). Updates golang#52919. Updates golang#54313. Updates golang#57261. Updates golang#58385. Change-Id: I4591bfb15501f04b7afe1fcd50c4fb93c86db63d Reviewed-on: https://go-review.googlesource.com/c/go/+/466935 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
…ocal" Update the code that tries to satisfy unresolved references to "__stack_chk_fail_local" to look for "libssp_nonshared.a" in addition to "libc_nonshared.a" (the former archive is the correct place on Alpine). Updates golang#52919. Updates golang#54313. Updates golang#57261. Fixes golang#58385. Change-Id: Id6cd3ebb4d5388df50a838e6efa5e5b683545b01 Reviewed-on: https://go-review.googlesource.com/c/go/+/466936 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
[ commit ea935baf6775d139ddc1d894259c745949b33605 ] See: golang/go#58385
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, though for different reasons.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
With current Git HEAD (or any commit after 066b780) on an i386 system running Alpine Linux:
./make.bash
./run.bash
What did you expect to see?
A successful pass of the test suite.
What did you see instead?
Multiple test failures with the following error message:
Why does this happen?
Commit 066b780 (CC: @thanm) removed the
-fno-stack-protector
C compiler flag from the cgo runtime (see #52919 and #54313 for more information on why this was needed in the first place). Instead, the commit modifiedcmd/link
to also link againstlibc_nonshared.a
if__stack_chk_fail_local
is an unresolved symbol. This is needed on i386 as GCC emitslocal
calls to__stack_chk_fail_local
on this architecture but not on 64-bit architectures, hence this issue can only be reproduced on i386. Unfortunately, linking againstlibc_nonshared.a
is not portable as there is no guarantee that__stack_chk_fail_local
is defined by this library. On Alpine, the library providing this symbol is instead calledlibssp_nonshared.a
but it may be named differently on other musl-based Linux distributions [1].How can this be fixed?
I think it would be reasonable for 066b780 to be enhanced in a way that it also checks for
libc_nonshared.a
this would at least unbreak cgo on i386 Alpine Linux (though it is still not a portable solution), e.g.:With this patch, the majority of the test suite passes again. Unfortunately, tests performed without libgcc still fail:
This is because these tests are run with
-linkmode=internal -libgcc=none
and the code above is explicitly disabled iflibgcc
is none.go/src/cmd/link/internal/ld/lib.go
Lines 631 to 652 in 780db9a
As such, I would have expected these tests to also fail on i386 glibc-based Linux systems but wasn't able to test this hypothesis. If we change the code referenced above to also link against
libc_nonshared.a
/libssp_nonshared.a
, even with-libgcc none
, then all tests pass again on i386 Alpine Linux. I presently don't understand why the implementation does not resolve__stack_chk_fail_local
with-libgcc none
. Conceptually, I also don't understand why the internal linker is being used when cgo is involved, unconditionally using the external linker in conjunction with cgo should resolve all of those issues.The final patch that makes on the tests pass again for me looks like this:
Related Issues
The text was updated successfully, but these errors were encountered: