ARGoS crashes whenever I try to use the spatial_hash capability of the dynamics2d engine with multiple engines. If I set two physics engines (each has half the arena) and then 2 threads, ARGoS always crashes. If I then set ARGoS to only use 1 thread (keeping multiple physics engines), then the problem vanishes, so I suspect there is some global state which is not being protected by a lock. I also saw that using multiple physics engines where exactly ONE engine uses the spatial hash does not cause a crash, so I suspect that chipmunk uses global state for its hashing.
I've tried a range of (cell_size, cell_num) values, from (0.5, 1000) to (500, 10000), with the same result. I'm simulating a swarm of ~1000 foot-bots, using 16 physics engines (equally dividing a square arena).
A traceback with gdb is as follows:
Code: Select all
>>> bt
#0 0x00007ffff27c748b in cpHandleRelease (hand=0x0, pooledHandles=0x5555556fd840) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/chipmunk-physics/src/cpSpaceHash.c:71
#1 0x00007ffff27c7658 in clearTableCell (hash=0x5555556fa6d0, idx=1358) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/chipmunk-physics/src/cpSpaceHash.c:118
#2 0x00007ffff27c76c3 in clearTable (hash=0x5555556fa6d0) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/chipmunk-physics/src/cpSpaceHash.c:130
#3 0x00007ffff27c8411 in cpSpaceHashReindexQuery (hash=0x5555556fa6d0, func=0x7ffff27b34e5 <collideShapes>, data=0x5555556f6ba0) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/chip
munk-physics/src/cpSpaceHash.c:464
#4 0x00007ffff27b2bdb in cpSpatialIndexReindexQuery (index=0x5555556fa6d0, func=0x7ffff27b34e5 <collideShapes>, data=0x5555556f6ba0) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/
chipmunk-physics/include/cpSpatialIndex.h:233
#5 0x00007ffff27b3b29 in cpSpaceStep (space=0x5555556f6ba0, dt=0.02) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/chipmunk-physics/src/cpSpaceStep.c:374
#6 0x00007ffff27d48d3 in argos::CDynamics2DEngine::Update (this=0x5555556f6750) at /opt/jharwell/git/argos3/src/plugins/simulator/physics_engines/dynamics2d/dynamics2d_engine.cpp:116
#7 0x00007ffff7f71b23 in argos::CSpaceMultiThreadBalanceQuantity::UpdateThreadPhysics (this=0x5555555e1f90, c_range=...) at /opt/jharwell/git/argos3/src/core/simulator/space/space_multi_thread_balance_quantity.
cpp:377
#8 0x00007ffff7f7173d in argos::CSpaceMultiThreadBalanceQuantity::UpdateThread (this=0x5555555e1f90, un_id=13) at /opt/jharwell/git/argos3/src/core/simulator/space/space_multi_thread_balance_quantity.cpp:322
#9 0x00007ffff7f70683 in argos::LaunchUpdateThreadBalanceQuantity (p_data=0x5555593b8540) at /opt/jharwell/git/argos3/src/core/simulator/space/space_multi_thread_balance_quantity.cpp:44
#10 0x00007ffff6eec609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ffff7a9e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95