ilpincy/argos3-examples

Run-time errors under macOS

Closed this issue · 2 comments

I'm getting the run-time errors below under macOS Catalina 10.15.7 with the latest version of ARGoS (3.0.0-beta57). Everything works fine under Ubuntu 18.04, so maybe this is a quirk in the AddressSanitizer of Clang?

$ clang -v
Apple clang version 11.0.0 (clang-1100.0.33.16)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

The foraging example crashes on launch:

$ argos3 -c experiments/foraging.argos
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_qtopengl.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_dynamics3d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3core_simulator.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_pointmass3d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_media.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_entities.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_footbot.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_dynamics2d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_genericrobot.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_spiri.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_prototype.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_epuck.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_eyebot.dylib"
[INFO] Not using threads
[INFO] Using random seed = 123
[INFO] Using simulation clock tick = 0.1
[INFO] Total experiment length in clock ticks = unlimited
[INFO] Loaded library "./build/controllers/footbot_foraging/libfootbot_foraging.dylib"
[INFO] Loaded library "./build/loop_functions/foraging_loop_functions/libforaging_loop_functions.so"
=================================================================
==87849==ERROR: AddressSanitizer: container-overflow on address 0x606000071390 at pc 0x00010eab0072 bp 0x7ffee26fb560 sp 0x7ffee26fad10
READ of size 64 at 0x606000071390 thread T0
    #0 0x10eab0071 in __asan_memcpy (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x5c071)
    #1 0x1127b8d1f in std::__1::enable_if<((std::__1::integral_constant<bool, true>::value) || (!(__has_construct<std::__1::allocator<argos::CVector2>, bool*, bool>::value))) && (is_trivially_move_constructible<bool>::value), void>::type std::__1::allocator_traits<std::__1::allocator<argos::CVector2> >::__construct_backward<argos::CVector2>(std::__1::allocator<argos::CVector2>&, bool*, bool*, bool*&) memory:1700
    #2 0x1127b808a in std::__1::vector<argos::CVector2, std::__1::allocator<argos::CVector2> >::__swap_out_circular_buffer(std::__1::__split_buffer<argos::CVector2, std::__1::allocator<argos::CVector2>&>&) vector:938
    #3 0x1149b279b in void std::__1::vector<argos::CVector2, std::__1::allocator<argos::CVector2> >::__push_back_slow_path<argos::CVector2>(argos::CVector2&&) (libforaging_loop_functions.so:x86_64+0x1079b)
    #4 0x1149a6c96 in std::__1::vector<argos::CVector2, std::__1::allocator<argos::CVector2> >::push_back(argos::CVector2&&) (libforaging_loop_functions.so:x86_64+0x4c96)
    #5 0x1149a5e73 in CForagingLoopFunctions::Init(ticpp::Element&) (libforaging_loop_functions.so:x86_64+0x3e73)
    #6 0x10d6af509 in argos::CSimulator::Init() simulator.cpp:154
    #7 0x10d6afcdd in argos::CSimulator::LoadExperiment() simulator.cpp:124
    #8 0x10d523738 in main main.cpp:37
    #9 0x7fff70501cc8 in start (libdyld.dylib:x86_64+0x1acc8)

0x6060000713a0 is located 0 bytes to the right of 64-byte region [0x606000071360,0x6060000713a0)
allocated by thread T0 here:
    #0 0x10eabfd52 in wrap__Znwm (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x6bd52)
    #1 0x1149ac398 in std::__1::__libcpp_allocate(unsigned long, unsigned long) (libforaging_loop_functions.so:x86_64+0xa398)
    #2 0x1149b2ec2 in std::__1::allocator<argos::CVector2>::allocate(unsigned long, void const*) (libforaging_loop_functions.so:x86_64+0x10ec2)
    #3 0x1149b2d80 in std::__1::allocator_traits<std::__1::allocator<argos::CVector2> >::allocate(std::__1::allocator<argos::CVector2>&, unsigned long) (libforaging_loop_functions.so:x86_64+0x10d80)
    #4 0x1149b2cc9 in std::__1::__split_buffer<argos::CVector2, std::__1::allocator<argos::CVector2>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<argos::CVector2>&) (libforaging_loop_functions.so:x86_64+0x10cc9)
    #5 0x1149b298c in std::__1::__split_buffer<argos::CVector2, std::__1::allocator<argos::CVector2>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<argos::CVector2>&) (libforaging_loop_functions.so:x86_64+0x1098c)
    #6 0x1149b274c in void std::__1::vector<argos::CVector2, std::__1::allocator<argos::CVector2> >::__push_back_slow_path<argos::CVector2>(argos::CVector2&&) (libforaging_loop_functions.so:x86_64+0x1074c)
    #7 0x1149a6c96 in std::__1::vector<argos::CVector2, std::__1::allocator<argos::CVector2> >::push_back(argos::CVector2&&) (libforaging_loop_functions.so:x86_64+0x4c96)
    #8 0x1149a5e73 in CForagingLoopFunctions::Init(ticpp::Element&) (libforaging_loop_functions.so:x86_64+0x3e73)
    #9 0x10d6af509 in argos::CSimulator::Init() simulator.cpp:154
    #10 0x10d6afcdd in argos::CSimulator::LoadExperiment() simulator.cpp:124
    #11 0x10d523738 in main main.cpp:37
    #12 0x7fff70501cc8 in start (libdyld.dylib:x86_64+0x1acc8)

HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_container_overflow=0.
If you suspect a false positive see also: https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow.
SUMMARY: AddressSanitizer: container-overflow (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x5c071) in __asan_memcpy
Shadow bytes around the buggy address:
  0x1c0c0000e220: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
  0x1c0c0000e230: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00
  0x1c0c0000e240: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 00
  0x1c0c0000e250: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
  0x1c0c0000e260: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00
=>0x1c0c0000e270: 00 00[fc]fc fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0c0000e280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0c0000e290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0c0000e2a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0c0000e2b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0c0000e2c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==87849==ABORTING
[1]    87849 abort      argos3 -c experiments/foraging.argos

The trajectory example will launch, but crashes after running for a few seconds:

$ argos3 -c experiments/trajectory.argos
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_qtopengl.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_dynamics3d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3core_simulator.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_pointmass3d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_media.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_entities.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_footbot.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_dynamics2d.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_genericrobot.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_spiri.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_prototype.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_epuck.dylib"
[INFO] Loaded library "/usr/local/lib/argos3/libargos3plugin_simulator_eyebot.dylib"
[INFO] Not using threads
[INFO] Using random seed = 124
[INFO] Using simulation clock tick = 0.1
[INFO] Total experiment length in clock ticks = unlimited
[INFO] Loaded library "./build/controllers/footbot_diffusion/libfootbot_diffusion.so"
[INFO] Loaded library "./build/loop_functions/trajectory_loop_functions/libtrajectory_loop_functions.so"
[INFO] The physics engine "dyn2d" will perform 10 iterations per tick (dt = 0.01 sec)
[INFO] Loaded library "./build/loop_functions/trajectory_loop_functions/libtrajectory_loop_functions.so"
=================================================================
==89665==ERROR: AddressSanitizer: container-overflow on address 0x6080000d8b68 at pc 0x00010f5c4be6 bp 0x7ffee076eae0 sp 0x7ffee076ead8
READ of size 8 at 0x6080000d8b68 thread T0
    #0 0x10f5c4be5 in argos::CVector3::operator-=(argos::CVector3 const&) vector3.h:557
    #1 0x10f5c5992 in argos::CVector3::operator-(argos::CVector3 const&) const vector3.h:605
    #2 0x116b4c2e0 in argos::SquareDistance(argos::CVector3 const&, argos::CVector3 const&) (libtrajectory_loop_functions.so:x86_64+0x52e0)
    #3 0x116b4c228 in CTrajectoryLoopFunctions::PostStep() (libtrajectory_loop_functions.so:x86_64+0x5228)
    #4 0x10f7cf193 in argos::CSpace::Update() space.cpp:145
    #5 0x10f64adbd in argos::CSimulator::UpdateSpace() simulator.cpp:282
    #6 0x1148f059d in argos::CQTOpenGLWidget::StepExperiment() qtopengl_widget.cpp:514
    #7 0x1148f33b8 in argos::CQTOpenGLWidget::timerEvent(QTimerEvent*) qtopengl_widget.cpp:784
    #8 0x116626300 in QObject::event(QEvent*) (QtCore:x86_64+0x20f300)
    #9 0x11567cd76 in QWidget::event(QEvent*) (QtWidgets:x86_64+0x4dd76)
    #10 0x115642a55 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (QtWidgets:x86_64+0x13a55)
    #11 0x115643e01 in QApplication::notify(QObject*, QEvent*) (QtWidgets:x86_64+0x14e01)
    #12 0x11480bfa8 in argos::CQTOpenGLApplication::notify(QObject*, QEvent*) qtopengl_application.cpp:21
    #13 0x1165fd2b5 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (QtCore:x86_64+0x1e62b5)
    #14 0x11665e52a in QTimerInfoList::activateTimers() (QtCore:x86_64+0x24752a)
    #15 0x11b8de031  (libqcocoa.dylib:x86_64+0x3b031)
    #16 0x7fff363ad883 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (CoreFoundation:x86_64+0x84883)
    #17 0x7fff363ad822 in __CFRunLoopDoSource0 (CoreFoundation:x86_64+0x84822)
    #18 0x7fff363ad63c in __CFRunLoopDoSources0 (CoreFoundation:x86_64+0x8463c)
    #19 0x7fff363ac358 in __CFRunLoopRun (CoreFoundation:x86_64+0x83358)
    #20 0x7fff363ab952 in CFRunLoopRunSpecific (CoreFoundation:x86_64+0x82952)
    #21 0x7fff34fc6abc in RunCurrentEventLoopInMode (HIToolbox:x86_64+0x2fabc)
    #22 0x7fff34fc67d4 in ReceiveNextEventCommon (HIToolbox:x86_64+0x2f7d4)
    #23 0x7fff34fc6578 in _BlockUntilNextEventMatchingListInModeWithFilter (HIToolbox:x86_64+0x2f578)
    #24 0x7fff3360c038 in _DPSNextEvent (AppKit:x86_64+0x41038)
    #25 0x7fff3360a87f in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (AppKit:x86_64+0x3f87f)
    #26 0x7fff335fc58d in -[NSApplication run] (AppKit:x86_64+0x3158d)
    #27 0x11b8ded73  (libqcocoa.dylib:x86_64+0x3bd73)
    #28 0x1165f96b6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (QtCore:x86_64+0x1e26b6)
    #29 0x1165fd851 in QCoreApplication::exec() (QtCore:x86_64+0x1e6851)
    #30 0x1148cb184 in argos::CQTOpenGLRender::Execute() qtopengl_render.cpp:65
    #31 0x10f64acea in argos::CSimulator::Execute() simulator.cpp:274
    #32 0x10f4ae749 in main main.cpp:38
    #33 0x7fff70501cc8 in start (libdyld.dylib:x86_64+0x1acc8)

0x6080000d8b68 is located 72 bytes inside of 96-byte region [0x6080000d8b20,0x6080000d8b80)
allocated by thread T0 here:
    #0 0x110de4d52 in wrap__Znwm (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x6bd52)
    #1 0x11a1e0118 in std::__1::__libcpp_allocate(unsigned long, unsigned long) new:239
    #2 0x11a1e7551 in std::__1::allocator<argos::CVector3>::allocate(unsigned long, void const*) memory:1814
    #3 0x11a1e7350 in std::__1::allocator_traits<std::__1::allocator<argos::CVector3> >::allocate(std::__1::allocator<argos::CVector3>&, unsigned long) memory:1547
    #4 0x11a1e7109 in std::__1::__split_buffer<argos::CVector3, std::__1::allocator<argos::CVector3>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<argos::CVector3>&) __split_buffer:311
    #5 0x11a1e672c in std::__1::__split_buffer<argos::CVector3, std::__1::allocator<argos::CVector3>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<argos::CVector3>&) __split_buffer:310
    #6 0x11a1e5b11 in void std::__1::vector<argos::CVector3, std::__1::allocator<argos::CVector3> >::__push_back_slow_path<argos::CVector3 const&>(argos::CVector3 const&) vector:1618
    #7 0x116b4bf21 in std::__1::vector<argos::CVector3, std::__1::allocator<argos::CVector3> >::push_back(argos::CVector3 const&) (libtrajectory_loop_functions.so:x86_64+0x4f21)
    #8 0x116b4c273 in CTrajectoryLoopFunctions::PostStep() (libtrajectory_loop_functions.so:x86_64+0x5273)
    #9 0x10f7cf193 in argos::CSpace::Update() space.cpp:145
    #10 0x10f64adbd in argos::CSimulator::UpdateSpace() simulator.cpp:282
    #11 0x1148f059d in argos::CQTOpenGLWidget::StepExperiment() qtopengl_widget.cpp:514
    #12 0x1148f33b8 in argos::CQTOpenGLWidget::timerEvent(QTimerEvent*) qtopengl_widget.cpp:784
    #13 0x116626300 in QObject::event(QEvent*) (QtCore:x86_64+0x20f300)
    #14 0x11567cd76 in QWidget::event(QEvent*) (QtWidgets:x86_64+0x4dd76)
    #15 0x115642a55 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (QtWidgets:x86_64+0x13a55)
    #16 0x115643e01 in QApplication::notify(QObject*, QEvent*) (QtWidgets:x86_64+0x14e01)
    #17 0x11480bfa8 in argos::CQTOpenGLApplication::notify(QObject*, QEvent*) qtopengl_application.cpp:21
    #18 0x1165fd2b5 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (QtCore:x86_64+0x1e62b5)
    #19 0x11665e52a in QTimerInfoList::activateTimers() (QtCore:x86_64+0x24752a)
    #20 0x11b8de031  (libqcocoa.dylib:x86_64+0x3b031)
    #21 0x7fff363ad883 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (CoreFoundation:x86_64+0x84883)
    #22 0x7fff363ad822 in __CFRunLoopDoSource0 (CoreFoundation:x86_64+0x84822)
    #23 0x7fff363ad63c in __CFRunLoopDoSources0 (CoreFoundation:x86_64+0x8463c)
    #24 0x7fff363ac358 in __CFRunLoopRun (CoreFoundation:x86_64+0x83358)
    #25 0x7fff363ab952 in CFRunLoopRunSpecific (CoreFoundation:x86_64+0x82952)
    #26 0x7fff34fc6abc in RunCurrentEventLoopInMode (HIToolbox:x86_64+0x2fabc)
    #27 0x7fff34fc67d4 in ReceiveNextEventCommon (HIToolbox:x86_64+0x2f7d4)
    #28 0x7fff34fc6578 in _BlockUntilNextEventMatchingListInModeWithFilter (HIToolbox:x86_64+0x2f578)
    #29 0x7fff3360c038 in _DPSNextEvent (AppKit:x86_64+0x41038)

HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_container_overflow=0.
If you suspect a false positive see also: https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow.
SUMMARY: AddressSanitizer: container-overflow vector3.h:557 in argos::CVector3::operator-=(argos::CVector3 const&)
Shadow bytes around the buggy address:
  0x1c100001b110: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
  0x1c100001b120: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
  0x1c100001b130: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
  0x1c100001b140: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
  0x1c100001b150: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
=>0x1c100001b160: fa fa fa fa 00 00 00 00 00 00 00 00 00[fc]fc fc
  0x1c100001b170: fa fa fa fa 00 00 00 00 00 00 00 00 00 fc fc fc
  0x1c100001b180: fa fa fa fa 00 00 00 00 00 00 00 00 00 fc fc fc
  0x1c100001b190: fa fa fa fa 00 00 00 00 00 00 00 00 00 fc fc fc
  0x1c100001b1a0: fa fa fa fa 00 00 00 00 00 00 00 00 00 fc fc fc
  0x1c100001b1b0: fa fa fa fa 00 00 00 00 00 00 00 00 00 fc fc fc
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==89665==ABORTING
[1]    89665 abort      argos3 -c experiments/trajectory.argos

Not sure if these are false-positives: https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow

If you compiled ARGoS under Mac not in Release mode, but either with Debug or RelWithDebInfo, then ARGoS under Mac is compiled with Asan support. In this case, compile the ARGoS examples with the CMake flag -DASAN=ON. This will install the Asan instrumentation also in the examples and remove the error (at least, if this is what is causing it!).

Thanks for the fast reply @ilpincy! That worked perfectly :)

Just as a reference for others: the flag -DCMAKE_BUILD_TYPE=Debug or -DCMAKE_BUILD_TYPE=RelWithDebInfo is also required for -DASAN=ON to take effect.