Commit 49bb8dcd authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Fix TSAN/ASAN wrt Debian testing

Current Debian testing builds libtsan/libasan with --as-needed, which
leads to not being linked in. Compare Debian 10:

    kirr@link:~/src/tools/go/pygolang$ ldd /usr/lib/x86_64-linux-gnu/ (0x00007ffe7e97f000) => /lib/x86_64-linux-gnu/ (0x00007f00ad9d5000) => /lib/x86_64-linux-gnu/ (0x00007f00ad9cb000) => /lib/x86_64-linux-gnu/ (0x00007f00ad9aa000) => /usr/lib/x86_64-linux-gnu/ (0x00007f00ad7d2000)		<-- libstdc++ => /lib/x86_64-linux-gnu/ (0x00007f00ad64f000) => /lib/x86_64-linux-gnu/ (0x00007f00ad48e000) => /lib/x86_64-linux-gnu/ (0x00007f00ad472000)
        /lib64/ (0x00007f00ae7c8000)

to Debian testing:

    kirr@deco:~/src/tools/go/pygolang$ ldd /usr/lib/x86_64-linux-gnu/ (0x00007ffe15d0b000) => /lib/x86_64-linux-gnu/ (0x00007f53ba069000) => /lib/x86_64-linux-gnu/ (0x00007f53ba047000) => /lib/x86_64-linux-gnu/ (0x00007f53b9f03000) => /lib/x86_64-linux-gnu/ (0x00007f53b9d3e000) => /lib/x86_64-linux-gnu/ (0x00007f53b9d24000)
        /lib64/ (0x00007f53baa6b000)

where libstdc++ is not being linked to

This leads to the following crash:

    golang/ ==181237==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_interceptors.cpp:333 "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
        #0 0x7f76aa9f4657  (/usr/lib/x86_64-linux-gnu/
        #1 0x7f76aaa11d5a  (/usr/lib/x86_64-linux-gnu/
        #2 0x7f76aa97ac14 in __cxa_throw (/usr/lib/x86_64-linux-gnu/
        #3 0x7f76a497a9ef in panic golang/runtime/libgolang.cpp:79
        #4 0x7f76a497e9a9 in _chanselect golang/runtime/libgolang.cpp:956
        #5 0x7f76a455573c in select<1> golang/libgolang.h:535
        #6 0x7f76a454fa4b in _test_select_inplace() golang/runtime/libgolang_test.cpp:417
        #7 0x7f76a452781e in __pyx_pf_6golang_12_golang_test_30test_select_inplace golang/_golang_test.cpp:4859
        #8 0x7f76a45277db in __pyx_pw_6golang_12_golang_test_31test_select_inplace golang/_golang_test.cpp:4821

explained by

-> work it around by manually preloading libstdc++ as well.
parent b938af8b
#!/usr/bin/env python
# Copyright (C) 2019 Nexedi SA and Contributors.
# Copyright (C) 2019-2020 Nexedi SA and Contributors.
# Kirill Smelkov <>
# This program is free software: you can Use, Study, Modify and Redistribute
......@@ -91,7 +91,22 @@ def main():
out = out.decode('utf-8')
_ = grep1(r"lib.san\.so\.. => ([^\s]+)", out)
if _ is not None:
ld_preload = ("LD_PRELOAD",
libxsan =
# Some distributions (e.g. Debian testing as of 20200918) build
# libtsan/libasan with --as-needed, which removes libstdc++ from
# linked-in DSOs and lead to runtime assert failure inside
# sanitizer library on e.g. exception throw. Work it around with
# explicitly including libstdc++ into LD_PRELOAD as well.
_ = grep1(r"libstdc\+\+\.so\.. => ([^\s]+)", out)
if _ is None:
print("trun %r: cannot detect to which libstdc++ %s is linked" % (sys.argv[1:], _golang_so.path), file=sys.stderr)
libstdcxx =
ld_preload = ("LD_PRELOAD", "%s %s" % (libxsan, libstdcxx))
elif 'darwin' in sys.platform:
# on darwin there is no ready out-of-the box analog of ldd, but
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment