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 libstdc++.so not being linked in. Compare Debian 10:

    kirr@link:~/src/tools/go/pygolang$ ldd /usr/lib/x86_64-linux-gnu/libasan.so.5
        linux-vdso.so.1 (0x00007ffe7e97f000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f00ad9d5000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f00ad9cb000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f00ad9aa000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f00ad7d2000)		<-- libstdc++
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f00ad64f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f00ad48e000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f00ad472000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f00ae7c8000)

to Debian testing:

    kirr@deco:~/src/tools/go/pygolang$ ldd /usr/lib/x86_64-linux-gnu/libasan.so.6
        linux-vdso.so.1 (0x00007ffe15d0b000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f53ba069000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f53ba047000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f53b9f03000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f53b9d3e000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f53b9d24000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f53baa6b000)

where libstdc++ is not being linked to libasan.so

This leads to the following crash:

    golang/golang_test.py::test_pyx_select_inplace ==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/libasan.so.6+0xb2657)
        #1 0x7f76aaa11d5a  (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xcfd5a)
        #2 0x7f76aa97ac14 in __cxa_throw (/usr/lib/x86_64-linux-gnu/libasan.so.6+0x38c14)
        #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 https://github.com/google/sanitizers/issues/934

-> work it around by manually preloading libstdc++ as well.
parent b938af8b
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (C) 2019 Nexedi SA and Contributors. # Copyright (C) 2019-2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com> # Kirill Smelkov <kirr@nexedi.com>
# #
# This program is free software: you can Use, Study, Modify and Redistribute # This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your # it under the terms of the GNU General Public License version 3, or (at your
...@@ -91,7 +91,22 @@ def main(): ...@@ -91,7 +91,22 @@ def main():
out = out.decode('utf-8') out = out.decode('utf-8')
_ = grep1(r"lib.san\.so\.. => ([^\s]+)", out) _ = grep1(r"lib.san\.so\.. => ([^\s]+)", out)
if _ is not None: if _ is not None:
ld_preload = ("LD_PRELOAD", _.group(1)) libxsan = _.group(1)
# 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.
# https://github.com/google/sanitizers/issues/934
# https://github.com/google/sanitizers/issues/934#issuecomment-649516500
_ = 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)
sys.exit(2)
libstdcxx = _.group(1)
ld_preload = ("LD_PRELOAD", "%s %s" % (libxsan, libstdcxx))
elif 'darwin' in sys.platform: elif 'darwin' in sys.platform:
# on darwin there is no ready out-of-the box analog of ldd, but # 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