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

From: Malte Frank Gerdes <[email-masked]>
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