openworm / sibernetic

This is a C++/OpenCL implementation of the PCISPH algorithm supplemented with a set of biomechanics related features applied to C. elegans locomotion
Other
361 stars 105 forks source link

Segmentation fault when pressing 1 or 2 to select demo simulation #169

Open clausagerskov opened 4 years ago

clausagerskov commented 4 years ago

after running build.cmd (ow-0.9) on Windows Docker with WSL 2 and running ./Release/Sibernetic, and pressing 1 or 2 when Sibernetic is running results in a segmentation fault.

clausagerskov commented 4 years ago

using valgrind to get diagnostics returns the following:

[[ Step 7 (total steps: unlimited, t in sim: 0.00014s) dt: 2e-05 (in s), time elapsed: 0.73 (in min) ]] _runHashParticles: 2.507 ms _runSort: 20.308 ms _runSortPostPass: 10.661 ms _runIndexx: 107.262 ms _runIndexPostPass: 1.491 ms _runFindNeighbors: 269.814 ms _runPCISPH: 276.738 ms 3 iteration(s) membraneHandling: 19.947 ms _readBuffer: 1.252 ms

_Total_step_time: 709.980 ms

graphics: 428.674 ms

FPS: 0.879 fps

==56== Invalid write of size 4 ==56== at 0x121E2F: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Address 0x8a26140 is 0 bytes inside a block of size 111,616 free'd ==56== at 0x4C3173B: operator delete (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144524: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char*, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Block was alloc'd at ==56== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144E75: owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper, int, char) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11193D: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== ==56== Invalid write of size 4 ==56== at 0x121E62: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Address 0x8a26144 is 4 bytes inside a block of size 111,616 free'd ==56== at 0x4C3173B: operator delete (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144524: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Block was alloc'd at ==56== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144E75: owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper, int, char) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11193D: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== ==56== Invalid write of size 4 ==56== at 0x121E96: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty*) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char*, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Address 0x8a26148 is 8 bytes inside a block of size 111,616 free'd ==56== at 0x4C3173B: operator delete[](void) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144524: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Block was alloc'd at ==56== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144E75: owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper, int, char) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11193D: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== ==56== Invalid write of size 4 ==56== at 0x121EA2: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty*) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Address 0x8a2614c is 12 bytes inside a block of size 111,616 free'd ==56== at 0x4C3173B: operator delete (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144524: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char*, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Block was alloc'd at ==56== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==56== by 0x144E75: owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper, int, char) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11193D: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== ==56== Invalid write of size 4 ==56== at 0x121D86: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==56== ==56== ==56== Process terminating with default action of signal 11 (SIGSEGV) ==56== Access not within mapped region at address 0x0 ==56== at 0x121D86: owHelper::loadConfiguration(float, float, float&, int, int&, owConfigProperty) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x1447B9: owPhysicsFluidSimulator::reset() (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x11178A: respondKey(unsigned char, int, int) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x5A74BF4: glutMainLoopEvent (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x5A74FF4: glutMainLoop (in /usr/lib/x86_64-linux-gnu/libglut.so.3.9.0) ==56== by 0x111C30: run(int, char**, bool) (in /home/claus/sibernetic/Release/Sibernetic) ==56== by 0x110302: main (in /home/claus/sibernetic/Release/Sibernetic) ==56== If you believe this happened as a result of a stack ==56== overflow in your program's main thread (unlikely but ==56== possible), you can try to increase the size of the ==56== main thread stack using the --main-stacksize= flag. ==56== The main thread stack size used in this run was 8388608. ==56== ==56== HEAP SUMMARY: ==56== in use at exit: 23,393,132 bytes in 162,022 blocks ==56== total heap usage: 2,018,256 allocs, 1,856,234 frees, 262,221,863 bytes allocated ==56== ==56== LEAK SUMMARY: ==56== definitely lost: 137,148 bytes in 5 blocks ==56== indirectly lost: 640 bytes in 2 blocks ==56== possibly lost: 6,000,972 bytes in 52,132 blocks ==56== still reachable: 17,254,372 bytes in 109,883 blocks ==56== of which reachable via heuristic: ==56== stdstring : 380,613 bytes in 5,572 blocks ==56== newarray : 9,360 bytes in 12 blocks ==56== suppressed: 0 bytes in 0 blocks ==56== Rerun with --leak-check=full to see details of leaked memory ==56== ==56== For counts of detected and suppressed errors, rerun with: -v ==56== Use --track-origins=yes to see where uninitialised values come from ==56== ERROR SUMMARY: 29816 errors from 50 contexts (suppressed: 1 from 1) Segmentation fault

clausagerskov commented 4 years ago

can confirm this happening on an Ubuntu machine, a Windows machine (compiled using Visual Studio 2019), WSL2 on same Windows machine, as well as a docker image, all running either ow-0.9 or newest version of Sibernetic

clausagerskov commented 2 years ago

when debugging on windows 10 x64 line 327 in owHelper.cpp has an acess violation: image

clausagerskov commented 2 years ago

this actually seems to happen with all shortcuts that change or load config files like "r", "1", and "2". could be that some variable is not initialized properly

clausagerskov commented 2 years ago

found the issue, someone removed this command: owHelper::preLoadConfiguration(config); from owPhysicsFluidSimulator::reset() right before config->initGridCells();
Readding it restores the button 1 and 2 demo functionality