neuronsimulator / nrn

NEURON Simulator
http://nrn.readthedocs.io
Other
407 stars 118 forks source link

AddressSanitizer: CHECK failed: asan_interceptors.cpp #3109

Closed nrnhines closed 1 month ago

nrnhines commented 1 month ago

My machine (ubuntu 24.04 gcc version 13.2.0) is exhibiting many failures. For example

cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=install -DNRN_ENABLE_RX3D=OFF -DCMAKE_BUILD_TYPE=Debug -DNRN_ENABLE_TESTS=ON -DNRN_SANITIZERS=address
ninja install
ctest -j 8 hoctests

gives 13 tests failed out of 35 and /home/hines/neuron/temp/bldsani/Testing/Temporary/LastTest.log show 13 fragments with

AddressSanitizer: CHECK failed: asan_interceptors.cpp:458 "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0) (tid=...

with following lines usually of the form

AddressSanitizer: CHECK failed: asan_interceptors.cpp:458 "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0) (tid=46457)
    #0 0x75dfe6b068c7 in CheckUnwind ../../../../src/libsanitizer/asan/asan_rtl.cpp:69
    #1 0x75dfe6b2ce8d in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common$
    #2 0x75dfe6af4064 in __cxa_throw ../../../../src/libsanitizer/asan/asan_interceptors.cpp:458
    #3 0x75dfe6af4064 in __cxa_throw ../../../../src/libsanitizer/asan/asan_interceptors.cpp:457
    #4 0x75dfe24e43ad in hoc_execerror_mes(char const*, char const*, int) /home/hines/neuron/temp/src/oc/hoc.cpp:655
    #5 0x75dfe24e446b in hoc_execerror(char const*, char const*) /home/hines/neuron/temp/src/oc/hoc.cpp:660

I found a solution at https://github.com/google/sanitizers/issues/934#issuecomment-1800125367 in the sense that running a test manually with

~/neuron/temp/test/hoctests/tests$ nrn-enable-sanitizer --preload python test_mview.py
    1 
AddressSanitizer: CHECK failed: asan_interceptors.cpp:458 "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0) (tid=43238)
    #0 0x727e441068c7 in CheckUnwind ../../../../src/libsanitizer/asan/asan_rtl.cpp:69
    #1 0x727e4412ce8d in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:86
    #2 0x727e440f4064 in __cxa_throw ../../../../src/libsanitizer/asan/asan_interceptors.cpp:458

fails but

~/neuron/temp/test/hoctests/tests$ unset LD_PRELOAD
~/neuron/temp/test/hoctests/tests$ export LD_PRELOAD="$(realpath "$(gcc -print-file-name=libasan.so)") $(realpath "$(gcc -print-file-name=libstdc++.so)")"
~/neuron/temp/test/hoctests/tests$ python test_mview.py
    1 
    -65 
    -65 
    -65 
    -65 
    1 
~/neuron/temp/test/hoctests/tests$

is successful.

nrnhines commented 1 month ago

I'm thinking that if LD_PRELOAD exists in the environment then ctest and nrn-enable-sanitizer --preload python should use it instead of constructing its own. This issue may not exist on any other machine/compiler.

nrnhines commented 1 month ago

Resolved with

NRN_OVERRIDE_LD_PRELOAD="$(realpath "$(gcc -print-file-name=libasan.so)") $(realpath "$(gcc -print-file-name=libstdc++.so)")" cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DNRN_ENABLE_TESTS=ON -DNRN_SANITIZERS=address