GNU bug report logs - #36823
gcc bug prevents go program from starting newer gcc results in race condition

Previous Next

Package: guix;

Reported by: Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>

Date: Sat, 27 Jul 2019 17:01:02 UTC

Severity: normal

To reply to this bug, email your comments to 36823 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to help-debbugs <at> gnu.org:
bug#36823; Package debbugs.gnu.org. (Sat, 27 Jul 2019 17:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>:
New bug report received and forwarded. Copy sent to help-debbugs <at> gnu.org. (Sat, 27 Jul 2019 17:01:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>
To: submit <at> debbugs.gnu.org
Subject: gcc bug prevents go program from starting newer gcc results in race
 condition
Date: Sat, 27 Jul 2019 18:37:41 +0200
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

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

The problem seems identical to [1].

I copmiled go-1.4 with gcc:lib from 7, 8 and 9 with no luck (the 9
variant even fails the tests due to a race condition somewhere, i read
that in some other bug report but can't find the ID). Error Message at
the end.

So is there any progress on this? I guess this is necessary to make the
execution 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 warnings
FAIL




bug reassigned from package 'debbugs.gnu.org' to 'guix'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 27 Jul 2019 17:17:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#36823; Package guix. (Sun, 04 Jul 2021 20:43:01 GMT) Full text and rfc822 format available.

Message #10 received at 36823 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>
Cc: 36823 <at> debbugs.gnu.org
Subject: Re: bug#36823: gcc bug prevents go program from starting newer gcc
 results in race condition
Date: Sun, 04 Jul 2021 13:41:54 -0700
[Message part 1 (text/plain, inline)]
Hello,

Thanks for the report.

Malte Frank Gerdes <malte.f.gerdes <at> 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 <at> 7 in my user profile, it works fine.
However.... I can still repro this issue with gcc-toolchain <at> 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:

[go-explicitly-set-CXX.patch (text/x-patch, inline)]
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)))
[Message part 3 (text/plain, inline)]
Hope that helps,
Sarah

Information forwarded to bug-guix <at> gnu.org:
bug#36823; Package guix. (Tue, 06 Jul 2021 13:17:01 GMT) Full text and rfc822 format available.

Message #13 received at 36823 <at> debbugs.gnu.org (full text, mbox):

From: Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 36823 <at> debbugs.gnu.org
Subject: Re: bug#36823: gcc bug prevents go program from starting newer gcc
 results in race condition
Date: Tue, 06 Jul 2021 15:14:30 +0200
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. Does
it make sense to keep this ticket open, because as you found out there
still /is/ a bug? 

(also just rediscovering the subject line: what the heck did i mean with
that?!)


Malte

Sarah Morgensen <iskarian <at> mgsn.dev> writes:

> Hello,
>
> Thanks for the report.
>
> Malte Frank Gerdes <malte.f.gerdes <at> 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 <at> 7 in my user profile, it works fine.
> However.... I can still repro this issue with gcc-toolchain <at> 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




This bug report was last modified 3 years and 340 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.