opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
759 stars 308 forks source link

Visualizer causes segfault in Python build_simple_arm_model example #3718

Open arwhalley opened 4 months ago

arwhalley commented 4 months ago

Mint 21.3 (Ubuntu 22.04 based) using opensim-gui build script.

Run opensim-core-source/Bindings/Python/examples/build_simple_arm_model.py using Python3.10. The visualizer window opens and immediately closes again, with the following:

[info] 'biceps' Parameter update for the damped-model: ActiveForceLengthCurve minimum value was 0.1 but is now 0.0. [reporter] /forceset/bice time ps fiber_force elbow_angle
0.0 1.180969 1.5707963

RuntimeError Traceback (most recent call last)

in ----> 1 import build_simple_arm_model ~/opensim-workspace/opensim-core-source/Bindings/Python/examples/build_simple_arm_model.py in 162 state.setTime(0) 163 manager.initialize(state) --> 164 state = manager.integrate(10.0) 165 166 # --------------------------------------------------------------------------- ~/.virtualenvs/nsp3/lib/python3.10/site-packages/opensim/simulation.py in integrate(self, finalTime) 17983 } 17984 """ > 17985 return _simulation.Manager_integrate(self, finalTime) 17986 17987 def getState(self): RuntimeError: std::exception in 'SimTK::State const & OpenSim::Manager::integrate(double)': SimTK Exception thrown at VisualizerProtocol.cpp:458: Error detected by Simbody method VisualizerProtocol: An attempt to write() 1 bytes to pipe 16 failed with errno=32 (Broken pipe). (Required condition 'status!=-1' was not met.) In addition, the /var/log/syslog has the following: Feb 23 09:55:13 CRAWLER-E10 kernel: [64055.684981] simbody-visuali[31715]: segfault at 56104a20d ip 00007fa60c96a25a sp 00007ffda6a64de0 error 4 in libglut.so.3.9.0[7fa60c966000+14000] Feb 23 09:55:13 CRAWLER-E10 kernel: [64055.684993] Code: 48 8b 05 a1 dd 02 00 80 78 1c 00 74 73 48 89 ef e8 fb fb ff ff 49 89 c0 48 85 c0 0f 84 88 00 00 00 48 85 db 0f 84 7f 00 00 00 <0f> b6 13 31 c0 84 d2 74 44 48 8d 73 01 31 c9 31 ff eb 1c 0f 1f 00 Feb 23 09:55:13 CRAWLER-E10 systemd[1]: Started Process Core Dump (PID 31752/UID 0). Feb 23 09:55:14 CRAWLER-E10 systemd-coredump[31753]: Process 31715 (simbody-visuali) of user 1001 dumped core.#012#012Found module linux-vdso.so.1 with build-id: 8ec5722947270e86e99b1821ecca259093c925b8#012Found module libicudata.so.70 wi th build-id: b1c2496dd0543023c7a19c961bb7f3abc818f465#012Found module liblzma.so.5 with build-id: b85da6c48eb60a646615392559483b93617ef265#012Found module libicuuc.so.70 with build-id: bef3ff1d70aadd68aab07d858a759360c8b919ae#012Found mod ule libpciaccess.so.0 with build-id: 4c93da952f83c1d085d4bdead692db544c79b004#012Found module libxml2.so.2 with build-id: 1cf4a22fbe15a77baca28e9c824592b8b5d852ff#012Found module libtinfo.so.6 with build-id: e22ba7829a55a0dec2201a0b6dac7b a236118561#012Found module libedit.so.2 with build-id: 9fcc3490de1a1f4919b1f6e398c99c7fa25f6863#012Found module libffi.so.8 with build-id: 59c2a6b204f74f358ca7711d2dfd349d88711f6a#012Found module libdrm_intel.so.1 with build-id: 78e82902c 2a74278a5bac31c6cb8361a78bf7586#012Found module libdrm_nouveau.so.2 with build-id: 717e881b4ee3b0bc2344b0f63c4fc10c84263f13#012Found module libdrm_amdgpu.so.1 with build-id: 55735af4f6152d6148117c98fa6db08ed1d34fe5#012Found module libelf. so.1 with build-id: 0eaf2d056fb292c3da2d99fa16c13d0ec798f121#012Found module libdrm_radeon.so.1 with build-id: 2c199d459f832a915a700e1a9234cf9e14656889#012Found module libsensors.so.5 with build-id: 0d5803327d5e32a301844fb819fd3c762f8e69f 6#012Found module libzstd.so.1 with build-id: 5d9d0d946a3154a748e87e17af9d14764519237b#012Found module libz.so.1 with build-id: 30840b79ac329ecbf1dec0bb60180eed256d319f#012Found module libLLVM-15.so.1 with build-id: 5d46c4221e9c32a1695da3 0bd95956dd9ce00984#012Found module iris_dri.so with build-id: 52a5aed7f25cf3f3191caa1073703cdac74d3d62#012Found module libxcb-xfixes.so.0 with build-id: d6f264cc06fb6c92b5ced2c8f373cf5a5bda0e09#012Found module libxcb-sync.so.1 with build- id: 657d8516621c4042b4b221ce1b3525f92467ef7e#012Found module libxcb-present.so.0 with build-id: a4f415af56b06f1f38d5a0339dd9828ff136b115#012Found module libxcb-dri3.so.0 with build-id: b6aa69fda711358025ae4dd29fa597866d29b8c5#012Found mod ule libxcb-randr.so.0 with build-id: 7af27bf3e608d5c06645ad4086788afe8a8447e7#012Found module libxshmfence.so.1 with build-id: f08296172ec7b676e1b371afc936e36add17366d#012Found module libexpat.so.1 with build-id: d212d1f61d04a1e60fccad1a8 c118428cfd9be42#012Found module libxcb-shm.so.0 with build-id: edb24ef4079aa423edcc50a3bb0dfb912fe8a57a#012Found module libXfixes.so.3 with build-id: a9c550a40b8154a3b4b5e2ac182bb50c013c3f18#012Found module libxcb-dri2.so.0 with build-id: dc5a2c2b0c9080fff87ea241e7298a7ac2f838e3#012Found module libX11-xcb.so.1 with build-id: 70f2a36d79c623f42fd70fa7ffb06d8877c74f16#012Found module libxcb-glx.so.0 with build-id: 975ca99dc81fe3349892acd1ddc8d2a169810352#012Found module libd rm.so.2 with build-id: 9c7cb19295d20e515902cb0710326a0b8d6394c8#012Found module libglapi.so.0 with build-id: aca6dcce398fd4458e1017c0f42bc36167e54231#012Found module libGLX_mesa.so.0 with build-id: 81f27aa4cfe213187c5a2dda6902a87fd132a76e #012Found module libmd.so.0 with build-id: cd2d2f71b3967ebde30e2aa43b8eb63339020c06#012Found module libbsd.so.0 with build-id: 9a6c72469251e2feb63e175ef5cb944ce6e00df3#012Found module libquadmath.so.0 with build-id: 0971ec4ac32513fe5d63a5 8cbe14d0719568098a#012Found module libXdmcp.so.6 with build-id: 6b60f99504aa1d3999ea02a14366d1a39d6c5dcf#012Found module libXau.so.6 with build-id: 7089b383cacbfc1760634a3be19a923e51fe3315#012Found module libgfortran.so.5 with build-id: d 5755267103cdbec7e9e2218286d99988a646d62#012Found module libXext.so.6 with build-id: 9fb1880e02dfa11a8c39cd1a170109de08302059#012Found module libxcb.so.1 with build-id: 1bef862a339557aa16c34c7a4b27f8f3aea90517#012Found module ld-linux-x86- 64.so.2 with build-id: 15921ea631d9f36502d20459c43e5c85b7d6ab76#012Found module libopenblas.so.0 with build-id: 9c787ab060e6f898e63bfb5fd90dfb864d71b63a#012Found module libOpenGL.so.0 with build-id: 19bb1d13712da197419d0359c3796da1f040e7d d#012Found module libGLX.so.0 with build-id: ac8b68a74f1ead77477f89bc98998ecb064e3ae5#012Found module libGLdispatch.so.0 with build-id: 19c339ecd74c020f1db1342213a07114f4baf5e0#012Found module libXxf86vm.so.1 with build-id: a32520dd34e48c b9c4bd756f64875be8a1ef5b54#012Found module libXi.so.6 with build-id: 8ff5a3ac871a90fd9d0a7917c61f748a41c6b5ee#012Found module libX11.so.6 with build-id: 37a5d7bbb78e3a99ea8376a7c80ea0c62fe06494#012Found module libc.so.6 with build-id: c28 9da5071a3399de893d2af81d6a30c62646e1e#012Found module libgcc_s.so.1 with build-id: e3a44e0da9c6e835d293ed8fd2882b4c4a87130c#012Found module libstdc++.so.6 with build-id: e37fe1a879783838de78cbc8c80621fa685d58a2#012Found module libm.so.6 w ith build-id: a88ef0199bd5e742ebd0c359edf5cb2be0ec08b5#012Found module libSimTKcommon.so.3.8 with build-id: bb80e47fb97530df5c5262251167c36b13bc0441#012Found module libGLU.so.1 with build-id: 5d73ff282a07967e74c0972ac9b09a3b0dc5efc7#012Fo und module libGL.so.1 with build-id: fe7c476406e1e41b511089398540d618177a7dcb#012Found module libglut.so.3 with build-id: 78d5a4495027f83555d616082e4f8fce7094c2b9#012Found module simbody-visualizer with build-id: 755328ba8ce5b927ebd31ace7 7fef520b0140290#012Stack trace of thread 31715:#012#0 0x00007fa60c96a25a glutBitmapLength (libglut.so.3 + 0x1a25a)#012#1 0x000056104924df1a _ZN4Menu4drawEii (simbody-visualizer + 0x22f1a)#012#2 0x00005610492428bb redrawDisplay (simbody -visualizer + 0x178bb)#012#3 0x00007fa60c97272b n/a (libglut.so.3 + 0x2272b)#012#4 0x00007fa60c9760c1 fgEnumWindows (libglut.so.3 + 0x260c1)#012#5 0x00007fa60c972cbb glutMainLoopEvent (libglut.so.3 + 0x22cbb)#012#6 0x00007fa60c973579 glutMainLoop (libglut.so.3 + 0x23579)#012#7 0x000056104923a8eb main (simbody-visualizer + 0xf8eb)#012#8 0x00007fa60bfc1d90 __libc_start_call_main (libc.so.6 + 0x29d90)#012#9 0x00007fa60bfc1e40 __libc_start_main_impl (libc.so.6 + 0x29e4 0)#012#10 0x000056104923b005 _start (simbody-visualizer + 0x10005)#012#012Stack trace of thread 31720:#012#0 0x00007fa60c0a0c9b __sched_yield (libc.so.6 + 0x108c9b)#012#1 0x00007fa609c418a2 n/a (libopenblas.so.0 + 0x3718a2)#012#2 0x000 07fa60c02cac3 start_thread (libc.so.6 + 0x94ac3)#012#3 0x00007fa60c0be850 __clone3 (libc.so.6 + 0x126850)#012#012Stack trace of thread 31737:#012#0 0x00007fa60c029117 __futex_abstimed_wait_common64 (libc.so.6 + 0x91117)#012#1 0x00007fa 60c02ba41 __pthread_cond_wait_common (libc.so.6 + 0x93a41)#012#2 0x00007fa5c649552d n/a (iris_dri.so + 0x11952d)#012#3 0x00007fa5c64458bb n/a (iris_dri.so + 0xc98bb)#012#4 0x00007fa5c649545b n/a (iris_dri.so + 0x11945b)#012#5 0x00007f a60c02cac3 start_thread (libc.so.6 + 0x94ac3)#012#6 0x00007fa60c0be850 __clone3 (libc.so.6 + 0x126850)#012#012Stack trace of thread 31735:#012#0 0x00007fa60c029117 __futex_abstimed_wait_common64 (libc.so.6 + 0x91117)#012#1 0x00007fa60c 02ba41 __pthread_cond_wait_common (libc.so.6 + 0x93a41)#012#2 0x00007fa5c649552d n/a (iris_dri.so + 0x11952d)#012#3 0x00007fa5c64458bb n/a (iris_dri.so + 0xc98bb)#012#4 0x00007fa5c649545b n/a (iris_dri.so + 0x11945b)#012#5 0x00007fa60 c02cac3 start_thread (libc.so.6 + 0x94ac3)#012#6 0x00007fa60c0be850 __clone3 (libc.so.6 + 0x126850)#012#012Stack trace of thread 31723:#012#0 0x00007fa60c029117 __futex_abstimed_wait_common64 (libc.so.6 + 0x91117)#012#1 0x00007fa60c02b a41 __pthread_cond_wait_common (libc.so.6 + 0x93a41)#012#2 0x00007fa60c686cb3 wait > (libSimTKcommon.so.3.8 + 0x190cb3)#012#3 0x00007fa60c2bd253 n/a (libstdc++.so.6 + 0xdc253) #012#4 0x00007fa60c02cac3 start_thread (libc.so.6 + 0x94ac3)#012#5 0x00007fa60c0be850 __clone3 (libc.so.6 + 0x126850)#012#012Stack trace of thread 31729:#012#0 0x00007fa60c029117 __futex_abstimed_wait_common64 (libc.so.6 + 0x91117)#012 #1 0x00007fa60c02ba41 __pthread_cond_wait_common (libc.so.6 + 0x93a41)#012#2 0x00007fa60c686cb3 wait > (libSimTKcommon.so.3.8 + 0x190cb3)#012#3 0x00007fa60c2bd253 n/a (libstd c++.so.6
aymanhab commented 4 months ago

Thanks for reporting @arwhalley I'm assuming you used your 3.10 environment to build in cmake and to run, please let me know otherwise

arwhalley commented 4 months ago

Hi Ayman, Yes, the Python3.10 environment was used for the build. Rob

On Fri, 1 Mar 2024 at 19:04, Ayman Habib @.***> wrote:

Thanks for reporting @arwhalley https://github.com/arwhalley I'm assuming you used your 3.10 environment to build in cmake and to run, please let me know otherwise

— Reply to this email directly, view it on GitHub https://github.com/opensim-org/opensim-core/issues/3718#issuecomment-1973761983, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARQR5L7I6RPRIQJKRBAQIHTYWDGNHAVCNFSM6AAAAABDWOHZZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZTG43DCOJYGM . You are receiving this because you were mentioned.Message ID: @.***>

arwhalley commented 4 months ago

Actually, the C++ example, built with VISUALIZER defined, behaves in exactly the same way, and gives the same broken pipe error. This seems to be connected with OpenSim::Model.setUseVisualizer architecture because the C++ double pendulum example, that creates a MultibodySystem instance and adds it to a Visualizer instance during construction, works perfectly. Unfortunately, that latter API doesn't appear to be available for Python. In addition, I have tried the scripts on a fresh Ubuntu 22.04 installation with the same result.

aymanhab commented 4 months ago

Thanks for the update @arwhalley my conjecture is that the set of paths that simbody uses to search for the the visualizer executable maynot be complete or has baked in expectation of layout that's not satisfied. I assumed this has to do with the layout of the python package but based on your C++ example that's not accurate. Generally you can set an environment variable to tell simbody where to locate the visualizer as described here https://github.com/simbody/simbody/blob/6e7913c3851105f3d24b3fad2fdc4a42a7d86f50/Simbody/Visualizer/src/VisualizerProtocol.cpp#L253C21-L253C39 if you can set an environment variable and get the visualizer to work consistently that would be a good workaround. With a variety of settings for C++/Python/Matlab environments this may end up more robust than trying to guess the variety of layouts and baking the assumptions into the code anyway. Thank you

aymanhab commented 4 months ago

A minimal non working C++ setup would be best to troubleshoot if you can describe it (which example, running from what layout (build vs install) and what FHS setting was chosen in Cmake as it changes the installation layout.

arwhalley commented 3 months ago

I have tried setting SIMBODY_HOME and SimTK_INSTALL_DIR. I've checked that SIMBODY_VISUALIZER_INSTALL_DIR, used in the build, still refers to a valid directory. I've copied the simbody-visualizer executable into the current directory. I've created a symbolic link in the current directory to the simbody-visualizer.

I have compiled the simple_arm_model_build from https://simtk.org/api_docs/opensim/api_docs/md_doc_APIGuide.html and I've tried running from both build and install layouts.

My build was created using the opensim-gui build script and hence its layout is $HOME/opensim-core and $HOME/opensim-workspace, and it has installed into /opt/opensim-gui.

Having said all that, the visualizer window opens every time. Sometimes it works correctly, but more often the window is briefly black, and then closes, with the segfault and error messages complaining of a broken pipe. So I think that the search path must be correct, and the visualizer is found everytime. It seems to be more to do with the creation of the pipe itself.

johanna4711 commented 2 days ago

Any updates on this one?