gcc bug prevents go program from starting newer gcc results in race condition

OpenSubmitted by Malte Frank Gerdes.
Details
3 participants
  • Sarah Morgensen
  • Malte Frank Gerdes
  • Glenn Morris
Owner
unassigned
Severity
normal
M
M
Malte Frank Gerdes wrote on 27 Jul 2019 18:37
(address . submit@debbugs.gnu.org)
86wog3tove.fsf@gmail.com
Hi,
The precompiled version of Hugo-extended was not able to find someruntime dependencies: libstdc++.so.6 => not found libgcc_s.so.1 => not found
This seems like a version mismatch to me, so i built Hugo with thefollowing command: go build --tags extended
Now the error is (<HASH> = ypiv8dj4lkvsnm82s639h18l87frrh5g): /gnu/store/<HASH>-gcc-6.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found
The problem seems identical to [1].
I copmiled go-1.4 with gcc:lib from 7, 8 and 9 with no luck (the 9variant even fails the tests due to a race condition somewhere, i readthat in some other bug report but can't find the ID). Error Message atthe end.
So is there any progress on this? I guess this is necessary to make theexecution of hugo-extended (and maybe other programs?) work.

[1]: https://stackoverflow.com/questions/52663287/glibcxx-3-4-26-not-found
-Malte
##### ../misc/cgo/testsanitizers--- FAIL: TestShared (0.02s) --- FAIL: TestShared/tsan_shared (2.04s) cshared_test.go:71: `/tmp/guix-build-go-1.12.7.drv-0/TestShared821009189/tsan_shared` exited with exit status 66 ================== WARNING: ThreadSanitizer: data race (pid=3613) Write of size 8 at 0x7ffff6095c20 by thread T1: #0 pthread_attr_getstacksize <null> (tsan_shared+0x00000041d5b2) #1 x_cgo_init <null> (libtsan_shared.so+0x0000000968e0) #2 runtime.rt0_go <null> (libtsan_shared.so+0x00000008cb0e)
Previous write of size 8 at 0x7ffff6095c20 by main thread: #0 <null> <null> (0x000000000001)
Location is stack of thread T1.
Thread T1 (tid=3619, running) created by main thread at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 x_cgo_sys_thread_create <null> (libtsan_shared.so+0x000000096543) #3 _rt0_amd64_lib <null> (libtsan_shared.so+0x00000008ca16)
SUMMARY: ThreadSanitizer: data race ??:0 pthread_attr_getstacksize ================== ================== WARNING: ThreadSanitizer: data race (pid=3613) Read of size 8 at 0x7d080000dfe0 by thread T2: #0 threadentry <null> (libtsan_shared.so+0x000000096b03)
Previous write of size 8 at 0x7d080000dfe0 by thread T1: #0 malloc <null> (tsan_shared+0x00000040c2d3) #1 x_cgo_thread_start <null> (libtsan_shared.so+0x00000009716c) #2 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e546)
Location is heap block of size 24 at 0x7d080000dfe0 allocated by thread T1: #0 malloc <null> (tsan_shared+0x00000040c2d3) #1 x_cgo_thread_start <null> (libtsan_shared.so+0x00000009716c) #2 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e546)
Thread T2 (tid=3621, running) created by thread T1 at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 _cgo_sys_thread_start <null> (libtsan_shared.so+0x000000096a42) #3 x_cgo_thread_start <null> (libtsan_shared.so+0x0000000971fa) #4 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e546)
Thread T1 (tid=3619, running) created by main thread at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 x_cgo_sys_thread_create <null> (libtsan_shared.so+0x000000096543) #3 _rt0_amd64_lib <null> (libtsan_shared.so+0x00000008ca16)
SUMMARY: ThreadSanitizer: data race ??:0 threadentry ================== ================== WARNING: ThreadSanitizer: data race (pid=3613) Read of size 8 at 0x7ffff7fcc8b8 by thread T2: #0 threadentry <null> (libtsan_shared.so+0x000000096b36)
Previous write of size 8 at 0x7ffff7fcc8b8 by thread T1: #0 x_cgo_init <null> (libtsan_shared.so+0x000000096874) #1 runtime.rt0_go <null> (libtsan_shared.so+0x00000008cb0e)
Location is global 'setg_gcc' of size 8 at 0x7ffff7fcc8b8 (libtsan_shared.so+0x00000013a8b8)
Thread T2 (tid=3621, running) created by thread T1 at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 _cgo_sys_thread_start <null> (libtsan_shared.so+0x000000096a42) #3 x_cgo_thread_start <null> (libtsan_shared.so+0x0000000971fa) #4 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e546)
Thread T1 (tid=3619, running) created by main thread at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 x_cgo_sys_thread_create <null> (libtsan_shared.so+0x000000096543) #3 _rt0_amd64_lib <null> (libtsan_shared.so+0x00000008ca16)
SUMMARY: ThreadSanitizer: data race ??:0 threadentry ================== ================== WARNING: ThreadSanitizer: data race (pid=3613) Read of size 8 at 0x7d080000df80 by thread T6: #0 threadentry <null> (libtsan_shared.so+0x000000096b03)
Previous write of size 8 at 0x7d080000df80 by thread T1: #0 malloc <null> (tsan_shared+0x00000040c2d3) #1 x_cgo_thread_start <null> (libtsan_shared.so+0x00000009716c) #2 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e507)
Location is heap block of size 24 at 0x7d080000df80 allocated by thread T1: #0 malloc <null> (tsan_shared+0x00000040c2d3) #1 x_cgo_thread_start <null> (libtsan_shared.so+0x00000009716c) #2 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e507)
Thread T6 (tid=3625, running) created by thread T1 at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 _cgo_sys_thread_start <null> (libtsan_shared.so+0x000000096a42) #3 x_cgo_thread_start <null> (libtsan_shared.so+0x0000000971fa) #4 runtime.asmcgocall <null> (libtsan_shared.so+0x00000008e507)
Thread T1 (tid=3619, running) created by main thread at: #0 pthread_create <null> (tsan_shared+0x00000040dec4) #1 _cgo_try_pthread_create <null> (libtsan_shared.so+0x0000000967a1) #2 x_cgo_sys_thread_create <null> (libtsan_shared.so+0x000000096543) #3 _rt0_amd64_lib <null> (libtsan_shared.so+0x00000008ca16)
SUMMARY: ThreadSanitizer: data race ??:0 threadentry ================== ThreadSanitizer: reported 4 warningsFAIL
G
G
Glenn Morris wrote on 27 Jul 2019 19:16
control message for bug 36823
(address . control@debbugs.gnu.org)
E1hrQIu-00071C-Ky@fencepost.gnu.org
reassign 36823 guix
S
S
Sarah Morgensen wrote on 4 Jul 22:41 +0200
Re: bug#36823: gcc bug prevents go program from starting newer gcc results in race condition
(name . Malte Frank Gerdes)(address . malte.f.gerdes@gmail.com)(address . 36823@debbugs.gnu.org)
86fswtak19.fsf@mgsn.dev
Hello,
Thanks for the report.
Malte Frank Gerdes <malte.f.gerdes@gmail.com> writes:
Toggle quote (7 lines)> Hi,>> The precompiled version of Hugo-extended was not able to find some> runtime dependencies:> libstdc++.so.6 => not found> libgcc_s.so.1 => not found
In case you haven't discovered this in the past two years (oops), thisis because Guix does not typically work with pre-compiled software thatrelies on system libraries being in /lib, since there is no system-wide/lib.
Toggle quote (8 lines)> This seems like a version mismatch to me, so i built Hugo with the> following command:> go build --tags extended>> Now the error is (<HASH> = ypiv8dj4lkvsnm82s639h18l87frrh5g):> /gnu/store/<HASH>-gcc-6.5.0-lib/lib/libstdc++.so.6: version> `GLIBCXX_3.4.26' not found
If I build hugo with gcc-toolchain@7 in my user profile, it works fine.However.... I can still repro this issue with gcc-toolchain@8+:
$ go build --tags extended$ ./hugo --help./hugo: /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./hugo)./hugo: /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./hugo)
This is because gcc 7's libraries are shadowing the newer gcc'slibraries:
$ readelf -d hugo | grep RUNPATH 0x000000000000001d (RUNPATH) Library runpath: [/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib:/gnu/store/3h7xd0d47a286b6r9qhz4ybi5iaxkfwi-gcc-11.1.0-lib/lib:/home/sarah/.guix-profile/lib:/gnu/store/3h7xd0d47a286b6r9qhz4ybi5iaxkfwi-gcc-11.1.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.1.0/../../..]
If I use patchelf to remove the gcc 7 library dir from RUNPATH, hugoworks fine. This is because Go is patched to unconditionally add arunpath to gcc 7's libraries but erroneously does not explicitly setCXX. (See also https://issues.guix.gnu.org/39400.)
The following patch should explicitly set CXX for Go, so that it alwaysuses the "system" version:
Toggle diff (20 lines)diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scmindex 0318918a37..a27f57aa30 100644--- a/gnu/packages/golang.scm+++ b/gnu/packages/golang.scm@@ -395,6 +395,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") ;; FIXME: Some of the .a files are not bit-reproducible. (let* ((output (assoc-ref outputs "out"))) (setenv "CC" (which "gcc"))+ (setenv "CXX" (which "g++")) (setenv "GOOS" "linux") (setenv "GOROOT" (dirname (getcwd))) (setenv "GOROOT_FINAL" output)@@ -577,6 +578,7 @@ in the style of communicating sequential processes (@dfn{CSP}).") (loader (string-append (assoc-ref inputs "libc") ,(glibc-dynamic-linker)))) (setenv "CC" (which "gcc"))+ (setenv "CXX" (which "g++")) (setenv "GO_LDSO" loader) (setenv "GOOS" "linux") (setenv "GOROOT" (dirname (getcwd)))
Hope that helps,Sarah
M
M
Malte Frank Gerdes wrote on 6 Jul 15:14 +0200
(name . Sarah Morgensen)(address . iskarian@mgsn.dev)(address . 36823@debbugs.gnu.org)
868s2jbn49.fsf@gmail.com
Thanks for your answer :-)
I don't use hugo anymore but at least i now know what the problem was,but i really appreciate that you took the time to reproduce this. Doesit make sense to keep this ticket open, because as you found out therestill /is/ a bug?
(also just rediscovering the subject line: what the heck did i mean withthat?!)

Malte
Sarah Morgensen <iskarian@mgsn.dev> writes:
Toggle quote (73 lines)> Hello,>> Thanks for the report.>> Malte Frank Gerdes <malte.f.gerdes@gmail.com> writes:>>> Hi,>>>> The precompiled version of Hugo-extended was not able to find some>> runtime dependencies:>> libstdc++.so.6 => not found>> libgcc_s.so.1 => not found>> In case you haven't discovered this in the past two years (oops), this> is because Guix does not typically work with pre-compiled software that> relies on system libraries being in /lib, since there is no system-wide> /lib.>>> This seems like a version mismatch to me, so i built Hugo with the>> following command:>> go build --tags extended>>>> Now the error is (<HASH> = ypiv8dj4lkvsnm82s639h18l87frrh5g):>> /gnu/store/<HASH>-gcc-6.5.0-lib/lib/libstdc++.so.6: version>> `GLIBCXX_3.4.26' not found>> If I build hugo with gcc-toolchain@7 in my user profile, it works fine.> However.... I can still repro this issue with gcc-toolchain@8+:>> $ go build --tags extended> $ ./hugo --help> ./hugo: /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./hugo)> ./hugo: /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./hugo)>> This is because gcc 7's libraries are shadowing the newer gcc's> libraries:>> $ readelf -d hugo | grep RUNPATH> 0x000000000000001d (RUNPATH) Library runpath:> [/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib:/gnu/store/3h7xd0d47a286b6r9qhz4ybi5iaxkfwi-gcc-11.1.0-lib/lib:/home/sarah/.guix-profile/lib:/gnu/store/3h7xd0d47a286b6r9qhz4ybi5iaxkfwi-gcc-11.1.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.1.0/../../..]>> If I use patchelf to remove the gcc 7 library dir from RUNPATH, hugo> works fine. This is because Go is patched to unconditionally add a> runpath to gcc 7's libraries but erroneously does not explicitly set> CXX. (See also <https://issues.guix.gnu.org/39400>.)>> The following patch should explicitly set CXX for Go, so that it always> uses the "system" version:>> diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm> index 0318918a37..a27f57aa30 100644> --- a/gnu/packages/golang.scm> +++ b/gnu/packages/golang.scm> @@ -395,6 +395,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")> ;; FIXME: Some of the .a files are not bit-reproducible.> (let* ((output (assoc-ref outputs "out")))> (setenv "CC" (which "gcc"))> + (setenv "CXX" (which "g++"))> (setenv "GOOS" "linux")> (setenv "GOROOT" (dirname (getcwd)))> (setenv "GOROOT_FINAL" output)> @@ -577,6 +578,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")> (loader (string-append (assoc-ref inputs "libc")> ,(glibc-dynamic-linker))))> (setenv "CC" (which "gcc"))> + (setenv "CXX" (which "g++"))> (setenv "GO_LDSO" loader)> (setenv "GOOS" "linux")> (setenv "GOROOT" (dirname (getcwd)))>>> Hope that helps,> Sarah
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 36823@debbugs.gnu.org