nrn icon indicating copy to clipboard operation
nrn copied to clipboard

Fix remaining UndefinedBehaviourSanitizer errors

Open olupton opened this issue 2 years ago • 1 comments

Context

In https://github.com/neuronsimulator/nrn/pull/1479 and https://github.com/BlueBrain/CoreNeuron/pull/652 I addressed several issues flagged by the LLVM undefined behaviour sanitizer. This issue describes the issues that are not fixed in those changesets.

The latest list of outstanding issues is in the suppression file used in the CI: https://github.com/neuronsimulator/nrn/blob/master/.sanitizers/undefined.supp.

Now that https://github.com/neuronsimulator/nrn/pull/1842 is merged, it should be sufficient to:

  • Build with Clang (Clang 14 is used in the CI), using -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ or similar
  • Pass -DNRN_SANITIZERS=undefined -DNRN_ENABLE_TESTS=ON -DCORENRN_SANITIZERS=undefined to enable UBSan

Below is some older information, which is less up-to-date than the above

Older information

Overview of the issue

With the two changesets above, running the CTest suite locally (on a machine with no GPU) produces 80 messages like:

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in

in total there are 11 different problematic expressions:

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:984:32 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:991:8 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:992:8 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:993:12 in

and these are triggered in the tests:

"parallel_bas" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:984:32 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:991:8 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:992:8 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:993:12 in
"parallel_bas" end time: Oct 05 17:24 CEST
"coreneuron_modtests::spikes_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
"coreneuron_modtests::spikes_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::spikes_file_mode_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
"coreneuron_modtests::spikes_file_mode_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::fornetcon_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"coreneuron_modtests::fornetcon_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::datareturn_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"coreneuron_modtests::datareturn_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::test_netmove_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"coreneuron_modtests::test_netmove_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::spikes_mpi_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
"coreneuron_modtests::spikes_mpi_py" end time: Oct 05 17:24 CEST
"coreneuron_modtests::spikes_mpi_file_mode_py" start time: Oct 05 17:24 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
"coreneuron_modtests::spikes_mpi_file_mode_py" end time: Oct 05 17:25 CEST
"external_ringtest::neuron" start time: Oct 05 17:25 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"external_ringtest::neuron" end time: Oct 05 17:25 CEST
"external_ringtest::neuron_mpi" start time: Oct 05 17:25 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"external_ringtest::neuron_mpi" end time: Oct 05 17:25 CEST
"external_ringtest::coreneuron_cpu_mpi" start time: Oct 05 17:25 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"external_ringtest::coreneuron_cpu_mpi" end time: Oct 05 17:25 CEST
"external_ringtest::coreneuron_cpu_mpi_offline::preparation" start time: Oct 05 17:25 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"external_ringtest::coreneuron_cpu_mpi_offline::preparation" end time: Oct 05 17:25 CEST
"external_ringtest::coreneuron_cpu_mpi_threads" start time: Oct 05 17:25 CEST
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
"external_ringtest::coreneuron_cpu_mpi_threads" end time: Oct 05 17:25 CEST

Example messages for each of the 11 SUMMARY: UndefinedBehavioirSanitizer: ... lines:

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28 in
/Users/olupton/build/nrn/src/nrniv/netpar.cpp:984:32: runtime error: member access within address 0x7f8ff1e81040 which does not point to an object of type 'PreSyn'
0x7f8ff1e81040: note: object has invalid vptr
 00 00 00 00  bd 7c 1e ff f8 07 00 00  c2 96 1e ff f8 07 00 30  0d 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
    #0 0x10cf9408e in nrnmpi_gid_clear(int) netpar.cpp:984
    #1 0x10d057998 in gid_clear(void*) ocbbs.cpp:639
    #2 0x10d1bbf16 in hoc_call_ob_proc hoc_oop.cpp:759
    #3 0x10d1bf0ed in hoc_object_component() hoc_oop.cpp:1174
    #4 0x10d5f735d in component(PyHocObject*) nrnpy_hoc.cpp:464
    #5 0x10d5f63df in fcall(void*, void*) nrnpy_hoc.cpp:660
    #6 0x10d05da2a in OcJumpImpl::fpycall(void* (*)(void*, void*), void*, void*) ocjump.cpp:222
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:16 in
/Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36: runtime error: member call on address 0x7f8ff1e93ab0 which does not point to an object of type 'ObjObservable'
0x7f8ff1e93ab0: note: object is of type 'ivObservable'
 01 00 00 00  98 b0 94 0d 01 00 00 00  d0 3a e9 f1 8f 7f 00 00  d0 22 f8 f1 8f 7f 00 00  40 0d 2e 13
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'ivObservable'
    #0 0x10ccfeaa3 in NetCon::disconnect(ivObservable*) netcvode.cpp:405
    #1 0x10d840c66 in ivObservable::~ivObservable() observe.cpp:47
    #2 0x10cccfc2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #3 0x10cccf454 in hoc_obj_disconnect ocobserv.cpp:10
    #4 0x10d1b9215 in hoc_obj_unref hoc_oop.cpp:2020
    #5 0x10d5fb209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:405:36 in
/Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28: runtime error: member access within address 0x7f8ff1e93ab0 which does not point to an object of type 'ObjObservable'
0x7f8ff1e93ab0: note: object is of type 'ivObservable'
 01 00 00 00  98 b0 94 0d 01 00 00 00  d0 3a e9 f1 8f 7f 00 00  d0 22 f8 f1 8f 7f 00 00  40 0d 2e 13
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'ivObservable'
    #0 0x10ccfed31 in ObjObservable::object() ocobserv.h:23
    #1 0x10ccfeac6 in NetCon::disconnect(ivObservable*) netcvode.cpp:405
    #2 0x10d840c66 in ivObservable::~ivObservable() observe.cpp:47
    #3 0x10cccfc2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #4 0x10cccf454 in hoc_obj_disconnect ocobserv.cpp:10
    #5 0x10d1b9215 in hoc_obj_unref hoc_oop.cpp:2020
    #6 0x10d5fb209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:31 in
/Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51: runtime error: member call on address 0x7ffa32cf7a20 which does not point to an object of type 'ObjObservable'
0x7ffa32cf7a20: note: object is of type 'ivObservable'
 00 00 00 00  98 e0 8b 0b 01 00 00 00  40 7a cf 32 fa 7f 00 00  00 79 cf 32 fa 7f 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'ivObservable'
    #0 0x10acea355 in PreSyn::disconnect(ivObservable*) netcvode.cpp:5148
    #1 0x10b7b3c66 in ivObservable::~ivObservable() observe.cpp:47
    #2 0x10ac42c2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #3 0x10ac42454 in hoc_obj_disconnect ocobserv.cpp:10
    #4 0x10b12c215 in hoc_obj_unref hoc_oop.cpp:2020
    #5 0x10b56e209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5148:51 in
/Users/olupton/build/nrn/src/ivoc/ocobserv.h:23:28: runtime error: member access within address 0x7ffa32cf7a20 which does not point to an object of type 'ObjObservable'
0x7ffa32cf7a20: note: object is of type 'ivObservable'
 00 00 00 00  98 e0 8b 0b 01 00 00 00  40 7a cf 32 fa 7f 00 00  00 79 cf 32 fa 7f 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'ivObservable'
    #0 0x10ac71d31 in ObjObservable::object() ocobserv.h:23
    #1 0x10acea37b in PreSyn::disconnect(ivObservable*) netcvode.cpp:5148
    #2 0x10b7b3c66 in ivObservable::~ivObservable() observe.cpp:47
    #3 0x10ac42c2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #4 0x10ac42454 in hoc_obj_disconnect ocobserv.cpp:10
    #5 0x10b12c215 in hoc_obj_unref hoc_oop.cpp:2020
    #6 0x10b56e209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:33 in
/Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53: runtime error: member call on address 0x7ffa32cf7a20 which does not point to an object of type 'ObjObservable'
0x7ffa32cf7a20: note: object is of type 'ivObservable'
 00 00 00 00  98 e0 8b 0b 01 00 00 00  40 7a cf 32 fa 7f 00 00  00 79 cf 32 fa 7f 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'ivObservable'
    #0 0x10acea51b in PreSyn::disconnect(ivObservable*) netcvode.cpp:5151
    #1 0x10b7b3c66 in ivObservable::~ivObservable() observe.cpp:47
    #2 0x10ac42c2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #3 0x10ac42454 in hoc_obj_disconnect ocobserv.cpp:10
    #4 0x10b12c215 in hoc_obj_unref hoc_oop.cpp:2020
    #5 0x10b56e209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrncvode/netcvode.cpp:5151:53 in
    #0 0x10e7d8862 in PreSyn::disconnect(ivObservable*) netcvode.cpp:5148
    #1 0x10f2a1c66 in ivObservable::~ivObservable() observe.cpp:47
    #2 0x10e730c2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #3 0x10e730454 in hoc_obj_disconnect ocobserv.cpp:10
    #4 0x10ec1a215 in hoc_obj_unref hoc_oop.cpp:2020
    #5 0x10f05c209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:984:32 in
/Users/olupton/build/nrn/src/nrniv/netpar.cpp:991:8: runtime error: member access within address 0x7f8ff1e81040 which does not point to an object of type 'PreSyn'
0x7f8ff1e81040: note: object has invalid vptr
 00 00 00 00  bd 7c 1e ff f8 07 00 00  c2 96 1e ff f8 07 00 30  0d 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
    #0 0x10cf940de in nrnmpi_gid_clear(int) netpar.cpp:991
    #1 0x10d057998 in gid_clear(void*) ocbbs.cpp:639
    #2 0x10d1bbf16 in hoc_call_ob_proc hoc_oop.cpp:759
    #3 0x10d1bf0ed in hoc_object_component() hoc_oop.cpp:1174
    #4 0x10d5f735d in component(PyHocObject*) nrnpy_hoc.cpp:464
    #5 0x10d5f63df in fcall(void*, void*) nrnpy_hoc.cpp:660
    #6 0x10d05da2a in OcJumpImpl::fpycall(void* (*)(void*, void*), void*, void*) ocjump.cpp:222
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:991:8 in
/Users/olupton/build/nrn/src/nrniv/netpar.cpp:992:8: runtime error: member access within address 0x7f8ff1e81040 which does not point to an object of type 'PreSyn'
0x7f8ff1e81040: note: object has invalid vptr
 00 00 00 00  bd 7c 1e ff f8 07 00 00  c2 96 1e ff f8 07 00 30  0d 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
    #0 0x10cf9411f in nrnmpi_gid_clear(int) netpar.cpp:992
    #1 0x10d057998 in gid_clear(void*) ocbbs.cpp:639
    #2 0x10d1bbf16 in hoc_call_ob_proc hoc_oop.cpp:759
    #3 0x10d1bf0ed in hoc_object_component() hoc_oop.cpp:1174
    #4 0x10d5f735d in component(PyHocObject*) nrnpy_hoc.cpp:464
    #5 0x10d5f63df in fcall(void*, void*) nrnpy_hoc.cpp:660
    #6 0x10d05da2a in OcJumpImpl::fpycall(void* (*)(void*, void*), void*, void*) ocjump.cpp:222
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:992:8 in
/Users/olupton/build/nrn/src/nrniv/netpar.cpp:993:12: runtime error: member access within address 0x7f8ff1e81040 which does not point to an object of type 'PreSyn'
0x7f8ff1e81040: note: object has invalid vptr
 00 00 00 00  bd 7c 1e ff f8 07 00 00  c2 96 1e ff f8 07 00 30  0d 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
    #0 0x10cf94158 in nrnmpi_gid_clear(int) netpar.cpp:993
    #1 0x10d057998 in gid_clear(void*) ocbbs.cpp:639
    #2 0x10d1bbf16 in hoc_call_ob_proc hoc_oop.cpp:759
    #3 0x10d1bf0ed in hoc_object_component() hoc_oop.cpp:1174
    #4 0x10d5f735d in component(PyHocObject*) nrnpy_hoc.cpp:464
    #5 0x10d5f63df in fcall(void*, void*) nrnpy_hoc.cpp:660
    #6 0x10d05da2a in OcJumpImpl::fpycall(void* (*)(void*, void*), void*, void*) ocjump.cpp:222
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/olupton/build/nrn/src/nrniv/netpar.cpp:993:12 in
0 {0: BallAndStick[0], 100: BallAndStick[100], 102: BallAndStick[102], 104: BallAndStick[104], 106: BallAndStick[106], 200: BallAndStick[200]}
0 {(0, 100): NetCon[6], (0, 102): NetCon[7], (0, 104): NetCon[8], (0, 106): NetCon[9], (100, 200): NetCon[10], (101, 200): NetCon[11], (102, 200): NetCon[12], (103, 200): NetCon[13], (104, 200): NetCon[14
], (105, 200): NetCon[15], (106, 200): NetCon[16], (107, 200): NetCon[17]}
    #0 0x10b120c52 in NetCon::disconnect(ivObservable*) netcvode.cpp:405
    #1 0x10bc62c66 in ivObservable::~ivObservable() observe.cpp:47
    #2 0x10b0f1c2f in ObjObservable::~ObjObservable() ocobserv.cpp:38
    #3 0x10b0f1454 in hoc_obj_disconnect ocobserv.cpp:10
    #4 0x10b5db215 in hoc_obj_unref hoc_oop.cpp:2020
    #5 0x10ba1d209 in hocobj_dealloc(PyHocObject*) nrnpy_hoc.cpp:185
...

(not sure about the BallAndStick[100] etc. in this last one... 🧐

Expected result/behavior

No tests should trigger undefined behaviour!

NEURON setup

  • Version: master with https://github.com/neuronsimulator/nrn/pull/1479 and https://github.com/BlueBrain/CoreNeuron/pull/652
  • Installation method: cmake build
  • OS + Version: macOS 11.6
  • Compiler + Version: AppleClang 13
cmake .. -G Ninja \
  -DCMAKE_C_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer -g" \
  -DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer -g" \
  -DNRN_ENABLE_CORENEURON=ON \
  -DCORENRN_ENABLE_NMODL=ON \
  -DNRN_ENABLE_TESTS=ON \
  -DNRN_ENABLE_INTERVIEWS=OFF \
  -DNRN_ENABLE_TESTS_BBP=ON \
  -DNRN_CLANG_FORMAT=ON \
  -DNRN_CMAKE_FORMAT=ON \
  -DNRN_FORMATTING_ON="since-ref:master" \
  -DNRN_FORMATTING_CPP_CHANGES_ONLY=ON
cmake --build . --parallel
export 'UBSAN_OPTIONS=print_stacktrace=1'
ctest -V

Logs

The test log from which the above stacktraces were extracted: LastTest.log

olupton avatar Oct 06 '21 07:10 olupton

I did attempt to fix some of these errors with https://github.com/neuronsimulator/nrn/commit/9391abad740e7e7ef3f74b90215240869366d575, but this caused other problems. A more joined-up approach is probably required.

olupton avatar Oct 06 '21 07:10 olupton