Crashing when loading user compiled plugins on Linux

Report crashes, strange behaviour, or apparent bugs
ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Crashing when loading user compiled plugins on Linux

Post by ahundt »

I'm getting crashes when loading my own plugins compiled on Linux. These plugins load perfectly on OS X, and ldd doesn't report any issues, with every dependent .so library correctly found. One particular detail is that I'm compiling with a very recent toolchain including gcc5.2 and c++11 support with an Ubuntu 14.04 LTS base platform.

What additional steps can I take to help debug this issue? I've encountered it before in a slightly different situation but I'm not sure I've ever been able to resolve it.

coppelia
Site Admin
Posts: 10361
Joined: 14 Dec 2012, 00:25

Re: Crashing when loading user compiled plugins on Linux

Post by coppelia »

Hello,

can you identify at what point it is crashing? In the initialization phase of the plugin? If yes, after what instruction exactly?

Cheers

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

How do I determine which line is failing? Should I figure out how to run with a debugger and step through? One difficulty is the program isn't crashing just the library is failing to load, so I'm not sure how to find the point of failure. If you're familiar with any instructions I could follow to debug it I'd appreciate a link.

It is printing the following:

Code: Select all

hbr@homebrew-robotics:~/V-REP_PRO_EDU_V3_2_2_64_Linux$ ./vrep.sh
Add-on script 'vrepAddOnScript-addOnScriptDemo.lua' was loaded.
glVersion: 2.1 Mesa 10.5.2
Simulator launched.
Plugin 'AtracsysFusionTrack': loading...
Plugin 'AtracsysFusionTrack': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'BubbleRob': loading...
Plugin 'BubbleRob': load succeeded.
Plugin 'Collada': loading...
Plugin 'Collada': load succeeded.
Plugin 'ConvexDecompose': loading...
Plugin 'ConvexDecompose': load succeeded.
Plugin 'DynamicsBullet': loading...
Plugin 'DynamicsBullet': load succeeded.
Plugin 'DynamicsNewton': loading...
Plugin 'DynamicsNewton': load succeeded.
Plugin 'DynamicsOde': loading...
Plugin 'DynamicsOde': load succeeded.
Plugin 'DynamicsVortex': loading...
Plugin 'DynamicsVortex': load succeeded.
Plugin 'ExternalRenderer': loading...
Plugin 'ExternalRenderer': load succeeded.
Plugin 'GrlInverseKinematics': loading...
Plugin 'GrlInverseKinematics': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'HandEyeCalibration': loading...
Plugin 'HandEyeCalibration': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'K3': loading...
Plugin 'K3': load succeeded.
Plugin 'KukaLBRiiwa': loading...
Plugin 'KukaLBRiiwa': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'LuaRemoteApiClient': loading...
Plugin 'LuaRemoteApiClient': load succeeded.
Plugin 'Mtb': loading...
Plugin 'Mtb': load succeeded.
Plugin 'OpenMesh': loading...
Plugin 'OpenMesh': load succeeded.
Plugin 'PovRay': loading...
Plugin 'PovRay': load succeeded.
Plugin 'Qhull': loading...
Plugin 'Qhull': load succeeded.
Plugin 'RRS1': loading...
Plugin 'RRS1': load succeeded.
Plugin 'ReflexxesTypeIV': loading...
Plugin 'ReflexxesTypeIV': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
Plugin 'RemoteApi': load succeeded.
Plugin 'Ros': loading...
Plugin 'Ros': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'SimpleFilter': loading...
Plugin 'SimpleFilter': load succeeded.
Plugin 'Urdf': loading...
Plugin 'Urdf': load succeeded.
Plugin 'Vision': loading...
Plugin 'Vision': load succeeded.
Using the internal 'MeshCalc' functionality.
Using the internal 'PathPlanning' functionality.




output of ldd for one example library is below, as you can see all libraries are reported as found. Perhaps it is noteworthy that these shared libraries

Code: Select all

hbr@homebrew-robotics:~/V-REP_PRO_EDU_V3_2_2_64_Linux$ ldd libv_repExtHandEyeCalibration.so 
	linux-vdso.so.1 (0x00007ffd8db48000)
	libboost_program_options-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_program_options-mt.so.1.58.0 (0x00007fc6a8f33000)
	libboost_filesystem-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_filesystem-mt.so.1.58.0 (0x00007fc6a8d1c000)
	libboost_unit_test_framework-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_unit_test_framework-mt.so.1.58.0 (0x00007fc6a8a74000)
	libboost_system-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_system-mt.so.1.58.0 (0x00007fc6a8871000)
	libboost_regex-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_regex-mt.so.1.58.0 (0x00007fc6a8590000)
	libboost_coroutine-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_coroutine-mt.so.1.58.0 (0x00007fc6a8382000)
	libboost_log-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_log-mt.so.1.58.0 (0x00007fc6a80aa000)
	libpthread.so.0 => /home/hbr/.linuxbrew/lib/libpthread.so.0 (0x00007fc6a7e8e000)
	libcamodocal_calib.so => /home/hbr/robonetracker/build/lib/libcamodocal_calib.so (0x00007fc6a7b8e000)
	libcamodocal_pose_graph.so => /home/hbr/robonetracker/build/lib/libcamodocal_pose_graph.so (0x00007fc6a794f000)
	libcamodocal_camera_systems.so => /home/hbr/robonetracker/build/lib/libcamodocal_camera_systems.so (0x00007fc6a773c000)
	libcamodocal_pugixml.so => /home/hbr/robonetracker/build/lib/libcamodocal_pugixml.so (0x00007fc6a7511000)
	libcamodocal_location_recognition.so => /home/hbr/robonetracker/build/lib/libcamodocal_location_recognition.so (0x00007fc6a72f1000)
	libcamodocal_DBoW2.so => /home/hbr/robonetracker/build/lib/libcamodocal_DBoW2.so (0x00007fc6a70dd000)
	libcamodocal_DUtilsCV.so => /home/hbr/robonetracker/build/lib/libcamodocal_DUtilsCV.so (0x00007fc6a6ea7000)
	libcamodocal_DVision.so => /home/hbr/robonetracker/build/lib/libcamodocal_DVision.so (0x00007fc6a6c79000)
	libcamodocal_DUtils.so => /home/hbr/robonetracker/build/lib/libcamodocal_DUtils.so (0x00007fc6a6a5b000)
	libcamodocal_visual_odometry.so => /home/hbr/robonetracker/build/lib/libcamodocal_visual_odometry.so (0x00007fc6a681c000)
	libcamodocal_camera_models.so => /home/hbr/robonetracker/build/lib/libcamodocal_camera_models.so (0x00007fc6a6478000)
	libcamodocal_gpl.so => /home/hbr/robonetracker/build/lib/libcamodocal_gpl.so (0x00007fc6a626f000)
	libcamodocal_sparse_graph.so => /home/hbr/robonetracker/build/lib/libcamodocal_sparse_graph.so (0x00007fc6a6054000)
	libcamodocal_pose_estimation.so => /home/hbr/robonetracker/build/lib/libcamodocal_pose_estimation.so (0x00007fc6a5e50000)
	libopencv_highgui.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_highgui.so.3.0 (0x00007fc6a5c4c000)
	libopencv_flann.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_flann.so.3.0 (0x00007fc6a5a12000)
	libcamodocal_brisk.so => /home/hbr/robonetracker/build/lib/libcamodocal_brisk.so (0x00007fc6a57fb000)
	libagast.so => /home/hbr/robonetracker/build/lib/libagast.so (0x00007fc6a55dd000)
	libopencv_imgproc.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_imgproc.so.3.0 (0x00007fc6a47c6000)
	libcamodocal_features2d.so => /home/hbr/robonetracker/build/lib/libcamodocal_features2d.so (0x00007fc6a45ad000)
	libopencv_imgcodecs.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_imgcodecs.so.3.0 (0x00007fc6a4243000)
	libopencv_xfeatures2d.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_xfeatures2d.so.3.0 (0x00007fc6a3fea000)
	libopencv_features2d.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_features2d.so.3.0 (0x00007fc6a3d6e000)
	libboost_serialization-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_serialization-mt.so.1.58.0 (0x00007fc6a3b0e000)
	libboost_thread-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_thread-mt.so.1.58.0 (0x00007fc6a38e9000)
	libcamodocal_fivepoint.so => /home/hbr/robonetracker/build/lib/libcamodocal_fivepoint.so (0x00007fc6a3694000)
	libopencv_core.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_core.so.3.0 (0x00007fc6a2b6e000)
	libopencv_calib3d.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_calib3d.so.3.0 (0x00007fc6a2894000)
	libceres.so => /home/hbr/robonetracker/build/lib/libceres.so (0x00007fc6a243d000)
	libgomp.so.1 => /home/hbr/.linuxbrew/lib/libgomp.so.1 (0x00007fc6a2222000)
	libgflags.so.2 => /home/hbr/.linuxbrew/lib/libgflags.so.2 (0x00007fc6a200e000)
	libdl.so.2 => /home/hbr/.linuxbrew/lib/libdl.so.2 (0x00007fc6a1e0a000)
	libnsl.so.1 => /home/hbr/.linuxbrew/lib/libnsl.so.1 (0x00007fc6a1bf5000)
	librt.so.1 => /home/hbr/.linuxbrew/lib/librt.so.1 (0x00007fc6a19ed000)
	libglog.so.0 => /home/hbr/.linuxbrew/lib/libglog.so.0 (0x00007fc6a17c4000)
	libtbb.so.2 => /home/hbr/.linuxbrew/lib/libtbb.so.2 (0x00007fc6a158a000)
	libtbbmalloc.so.2 => /home/hbr/.linuxbrew/lib/libtbbmalloc.so.2 (0x00007fc6a134d000)
	libstdc++.so.6 => /home/hbr/.linuxbrew/lib/libstdc++.so.6 (0x00007fc6a1019000)
	libm.so.6 => /home/hbr/.linuxbrew/lib/libm.so.6 (0x00007fc6a0d29000)
	libgcc_s.so.1 => /home/hbr/.linuxbrew/lib/libgcc_s.so.1 (0x00007fc6a0b18000)
	libc.so.6 => /home/hbr/.linuxbrew/lib/libc.so.6 (0x00007fc6a07a0000)
	libboost_context-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_context-mt.so.1.58.0 (0x00007fc6a0594000)
	libboost_chrono-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_chrono-mt.so.1.58.0 (0x00007fc6a038e000)
	libboost_date_time-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_date_time-mt.so.1.58.0 (0x00007fc6a017e000)
	/home/hbr/.linuxbrew/Cellar/glibc/2.19/lib64/ld-linux-x86-64.so.2 (0x00007fc6a93e4000)
	libopencv_videoio.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_videoio.so.3.0 (0x00007fc69ff6b000)
	libz.so.1 => /home/hbr/.linuxbrew/lib/libz.so.1 (0x00007fc69fd58000)
	libjpeg.so.8 => /home/hbr/.linuxbrew/lib/libjpeg.so.8 (0x00007fc69fb28000)
	libpng16.so.16 => /home/hbr/.linuxbrew/lib/libpng16.so.16 (0x00007fc69f900000)
	libtiff.so.5 => /home/hbr/.linuxbrew/lib/libtiff.so.5 (0x00007fc69f69c000)
	libImath-2_2.so.12 => /home/hbr/.linuxbrew/lib/libImath-2_2.so.12 (0x00007fc69f48d000)
	libIlmImf-2_2.so.22 => /home/hbr/.linuxbrew/lib/libIlmImf-2_2.so.22 (0x00007fc69efd8000)
	libIex-2_2.so.12 => /home/hbr/.linuxbrew/lib/libIex-2_2.so.12 (0x00007fc69edb9000)
	libHalf.so.12 => /home/hbr/.linuxbrew/lib/libHalf.so.12 (0x00007fc69eb77000)
	libIlmThread-2_2.so.12 => /home/hbr/.linuxbrew/lib/libIlmThread-2_2.so.12 (0x00007fc69e971000)
	libopencv_shape.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_shape.so.3.0 (0x00007fc69e758000)
	libopencv_video.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_video.so.3.0 (0x00007fc69e40a000)
	libopencv_ml.so.3.0 => /home/hbr/.linuxbrew/lib/libopencv_ml.so.3.0 (0x00007fc69e1b8000)
	libIexMath-2_2.so.12 => /home/hbr/.linuxbrew/lib/libIexMath-2_2.so.12 (0x00007fc69dfb5000)

Perhaps the fact that vrep is using some different versions of the same libraries will be a factor?

Code: Select all

hbr@homebrew-robotics:~/V-REP_PRO_EDU_V3_2_2_64_Linux$ ldd vrep
	linux-vdso.so.1 =>  (0x00007ffc98fe0000)
	liblua5.1.so => not found
	libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f431bdc7000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f431bba9000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f431b8a5000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f431b68f000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f431b2ca000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f431b0b1000)
	libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f431acaa000)
	libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f431a931000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f431a72d000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f431a425000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f431a21d000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4319f17000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f431c46d000)
	libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f43186aa000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f431846c000)


coppelia
Site Admin
Posts: 10361
Joined: 14 Dec 2012, 00:25

Re: Crashing when loading user compiled plugins on Linux

Post by coppelia »

Actually, when you launch V-REP with ./vrep.sh, there is an instruction in that script that tells to look for libraries in the current folder (export LD_LIBRARY_PATH). This also means that if you call ldd upon a library, you should use a similar approach to call it. Try a script with following content (not tested):

Code: Select all

#!/bin/sh

thisscript="$0"
while [ -L "$thisscript" ]; do
        thisscript="`readlink "$thisscript"`"
done

dirname=`dirname "$thisscript"`
if [ $dirname = "." ]; then
        dirname="$PWD"
fi

appname="`basename "$thisscript" | sed 's,\.sh$,,'`"

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$dirname"
export LD_LIBRARY_PATH
ldd "$dirname/libmyLib.so"
#"$dirname/$appname" "$@"
If you now call this script with ./myScript.sh, the ldd command in there should reflect better was is going on.

Cheers

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

Sorry I used the wrong description at the beginning of the post, vrep itself isn't crashing, rather the plugin is failing to load. Some of the material from another thread on plugin loading failure may be relevant, but the problem I solved in that case was for only one specific plugin failing to load on OS X. In this case all of them fail to load on Linux.

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

Here is the output of putting the results in the vrep.sh script as you described:

Code: Select all

hbr@homebrew-robotics:~/V-REP_PRO_EDU_V3_2_2_64_Linux$ ./vrep.sh
+ set -a
+ thisscript=./vrep.sh
+ [ -L ./vrep.sh ]
+ dirname ./vrep.sh
+ dirname=.
+ [ . = . ]
+ dirname=/home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux
+ basename ./vrep.sh
+ sed s,\.sh$,,
+ appname=vrep
+ LD_LIBRARY_PATH=~/.linuxbrew/lib::/home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux
+ export LD_LIBRARY_PATH
+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtGrlInverseKinematics.so
	linux-vdso.so.1 (0x00007ffdc1fc3000)
	libboost_program_options-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_program_options-mt.so.1.58.0 (0x00007f436e379000)
	libboost_filesystem-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_filesystem-mt.so.1.58.0 (0x00007f436e162000)
	libboost_unit_test_framework-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_unit_test_framework-mt.so.1.58.0 (0x00007f436deba000)
	libboost_system-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_system-mt.so.1.58.0 (0x00007f436dcb7000)
	libboost_regex-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_regex-mt.so.1.58.0 (0x00007f436d9d6000)
	libboost_coroutine-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_coroutine-mt.so.1.58.0 (0x00007f436d7c8000)
	libboost_log-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_log-mt.so.1.58.0 (0x00007f436d4f0000)
	libpthread.so.0 => /home/hbr/.linuxbrew/lib/libpthread.so.0 (0x00007f436d2d4000)
	libstdc++.so.6 => /home/hbr/.linuxbrew/lib/libstdc++.so.6 (0x00007f436cfa0000)
	libm.so.6 => /home/hbr/.linuxbrew/lib/libm.so.6 (0x00007f436ccb0000)
	libgcc_s.so.1 => /home/hbr/.linuxbrew/lib/libgcc_s.so.1 (0x00007f436ca9f000)
	libc.so.6 => /home/hbr/.linuxbrew/lib/libc.so.6 (0x00007f436c727000)
	librt.so.1 => /home/hbr/.linuxbrew/lib/librt.so.1 (0x00007f436c51f000)
	libboost_context-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_context-mt.so.1.58.0 (0x00007f436c313000)
	libboost_thread-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_thread-mt.so.1.58.0 (0x00007f436c0ee000)
	libboost_chrono-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_chrono-mt.so.1.58.0 (0x00007f436bee8000)
	libboost_date_time-mt.so.1.58.0 => /home/hbr/.linuxbrew/lib/libboost_date_time-mt.so.1.58.0 (0x00007f436bcd8000)
	/home/hbr/.linuxbrew/Cellar/glibc/2.19/lib64/ld-linux-x86-64.so.2 (0x00007f436e8d1000)
+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so
	linux-vdso.so.1 (0x00007ffc0fdb9000)
	libstdc++.so.6 => /home/hbr/.linuxbrew/lib/libstdc++.so.6 (0x00007fc38b48a000)
	libm.so.6 => /home/hbr/.linuxbrew/lib/libm.so.6 (0x00007fc38b19a000)
	libgcc_s.so.1 => /home/hbr/.linuxbrew/lib/libgcc_s.so.1 (0x00007fc38af89000)
	libc.so.6 => /home/hbr/.linuxbrew/lib/libc.so.6 (0x00007fc38ac11000)
	/home/hbr/.linuxbrew/Cellar/glibc/2.19/lib64/ld-linux-x86-64.so.2 (0x00007fc38b9d9000)
+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/vrep
	linux-vdso.so.1 =>  (0x00007ffc16f9f000)
	liblua5.1.so (0x00007f96465b6000)
	libQt5Core.so.5 (0x00007f9645d7b000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9645b5d000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9645859000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9645643000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f964527e000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9644f78000)
	libicui18n.so.54 (0x00007f9644b0a000)
	libicuuc.so.54 (0x00007f964475c000)
	libicudata.so.54 (0x00007f9642d32000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9642b2e000)
	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f964292c000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9642724000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f964241c000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f96464c0000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f96421de000)
+ /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/vrep
Add-on script 'vrepAddOnScript-addOnScriptDemo.lua' was loaded.
glVersion: 2.1 Mesa 10.5.2
Simulator launched.
Plugin 'AtracsysFusionTrack': loading...
Plugin 'AtracsysFusionTrack': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'BubbleRob': loading...
Plugin 'BubbleRob': load succeeded.
Plugin 'Collada': loading...
Plugin 'Collada': load succeeded.
Plugin 'ConvexDecompose': loading...
Plugin 'ConvexDecompose': load succeeded.
Plugin 'DynamicsBullet': loading...
Plugin 'DynamicsBullet': load succeeded.
Plugin 'DynamicsNewton': loading...
Plugin 'DynamicsNewton': load succeeded.
Plugin 'DynamicsOde': loading...
Plugin 'DynamicsOde': load succeeded.
Plugin 'DynamicsVortex': loading...
Plugin 'DynamicsVortex': load succeeded.
Plugin 'ExternalRenderer': loading...
Plugin 'ExternalRenderer': load succeeded.
Plugin 'GrlInverseKinematics': loading...
Plugin 'GrlInverseKinematics': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'HandEyeCalibration': loading...
Plugin 'HandEyeCalibration': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'K3': loading...
Plugin 'K3': load succeeded.
Plugin 'KukaLBRiiwa': loading...
Plugin 'KukaLBRiiwa': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'LuaRemoteApiClient': loading...
Plugin 'LuaRemoteApiClient': load succeeded.
Plugin 'Mtb': loading...
Plugin 'Mtb': load succeeded.
Plugin 'OpenMesh': loading...
Plugin 'OpenMesh': load succeeded.
Plugin 'PluginSkeleton': loading...
Plugin 'PluginSkeleton': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'PovRay': loading...
Plugin 'PovRay': load succeeded.
Plugin 'Qhull': loading...
Plugin 'Qhull': load succeeded.
Plugin 'RRS1': loading...
Plugin 'RRS1': load succeeded.
Plugin 'ReflexxesTypeIV': loading...
Plugin 'ReflexxesTypeIV': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
Plugin 'RemoteApi': load succeeded.
Plugin 'Ros': loading...
Plugin 'Ros': load failed (could not load). The plugin probably couldn't load dependency libraries. Try 'ldd pluginName.so' for more infos, or simply rebuild the plugin.
Plugin 'SimpleFilter': loading...
Plugin 'SimpleFilter': load succeeded.
Plugin 'Urdf': loading...
Plugin 'Urdf': load succeeded.
Plugin 'Vision': loading...
Plugin 'Vision': load succeeded.
Using the internal 'MeshCalc' functionality.
Using the internal 'PathPlanning' functionality.

Here is the vrep.sh script I used:

Code: Select all

#!/bin/sh
set -e
set -x
set -a

thisscript="$0"
while [ -L "$thisscript" ]; do
        thisscript="`readlink "$thisscript"`"
done

dirname=`dirname "$thisscript"`
if [ $dirname = "." ]; then
        dirname="$PWD"
fi

appname="`basename "$thisscript" | sed 's,\.sh$,,'`"

LD_LIBRARY_PATH="~/.linuxbrew/lib:$LD_LIBRARY_PATH:$dirname"
export LD_LIBRARY_PATH
ldd "$dirname/libv_repExtGrlInverseKinematics.so"
ldd "$dirname/libv_repExtPluginSkeleton.so"
ldd "$dirname/$appname"
"$dirname/$appname" "$@"


Here are the exact command line commands used in the build of the vrep plugin skeleton as output by make VERBOSE=1 libv_repExtPluginSkeleton:

Code: Select all

hbr@homebrew-robotics:~/robonetracker/build$ make VERBOSE=1 libv_repExtPluginSkeleton
make: *** No rule to make target 'libv_repExtPluginSkeleton'.  Stop.
hbr@homebrew-robotics:~/robonetracker/build$ make VERBOSE=1 v_repExtPluginSkeleton
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -H/home/hbr/robonetracker -B/home/hbr/robonetracker/build --check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 v_repExtPluginSkeleton
make[1]: Entering directory '/home/hbr/robonetracker/build'
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -H/home/hbr/robonetracker -B/home/hbr/robonetracker/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_progress_start /home/hbr/robonetracker/build/CMakeFiles 1
make -f CMakeFiles/Makefile2 modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/all
make[2]: Entering directory '/home/hbr/robonetracker/build'
make -f modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build.make modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/depend
make[3]: Entering directory '/home/hbr/robonetracker/build'
cd /home/hbr/robonetracker/build && /home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_depends "Unix Makefiles" /home/hbr/robonetracker /home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton /home/hbr/robonetracker/build /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/hbr/robonetracker/build'
make -f modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build.make modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build
make[3]: Entering directory '/home/hbr/robonetracker/build'
make[3]: Nothing to be done for 'modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build'.
make[3]: Leaving directory '/home/hbr/robonetracker/build'
[100%] Built target v_repExtPluginSkeleton
make[2]: Leaving directory '/home/hbr/robonetracker/build'
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_progress_start /home/hbr/robonetracker/build/CMakeFiles 0
make[1]: Leaving directory '/home/hbr/robonetracker/build'
hbr@homebrew-robotics:~/robonetracker/build$ make clean
hbr@homebrew-robotics:~/robonetracker/build$ make VERBOSE=1 v_repExtPluginSkeleton
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -H/home/hbr/robonetracker -B/home/hbr/robonetracker/build --check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 v_repExtPluginSkeleton
make[1]: Entering directory '/home/hbr/robonetracker/build'
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -H/home/hbr/robonetracker -B/home/hbr/robonetracker/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_progress_start /home/hbr/robonetracker/build/CMakeFiles 1
make -f CMakeFiles/Makefile2 modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/all
make[2]: Entering directory '/home/hbr/robonetracker/build'
make -f modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build.make modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/depend
make[3]: Entering directory '/home/hbr/robonetracker/build'
cd /home/hbr/robonetracker/build && /home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_depends "Unix Makefiles" /home/hbr/robonetracker /home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton /home/hbr/robonetracker/build /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/hbr/robonetracker/build'
make -f modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build.make modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/build
make[3]: Entering directory '/home/hbr/robonetracker/build'
[100%] Building CXX object modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/v_repExtPluginSkeleton.cpp.o
cd /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton && /home/hbr/.linuxbrew/bin/c++   -DBOOST_LOG_DYN_LINK -Dv_repExtPluginSkeleton_EXPORTS -fPIC -Wextra -Wall -std=c++11 -std=c++11 -DNDEBUG -O2                   -O3 -ftree-vectorize -ftree-vectorizer-verbose=0 -march=native -fPIC -I/home/hbr/robonetracker/modules/grl/src -isystem /home/hbr/robonetracker/modules/grl/include/thirdparty/vrep/include -I/home/hbr/robonetracker/modules/grl/include -I/home/hbr/robonetracker/build/include -I/home/hbr/robonetracker/thirdparty -I/home/hbr/robonetracker/include -I/home/hbr/.linuxbrew/include -I/home/hbr/robonetracker/build -I/home/hbr/.linuxbrew/include/eigen3 -I/home/hbr/robonetracker/modules/FRI-Client-SDK_Cpp/include -I/tmp/sawconstraintcontroller20151012-72486-ee97e1/include    -fPIC -fPIC -o CMakeFiles/v_repExtPluginSkeleton.dir/v_repExtPluginSkeleton.cpp.o -c /home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp: In function 'void LUA_GET_SENSOR_DATA_CALLBACK(SLuaCallBack*)':
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:58:8: warning: unused variable 'sensorIndex' [-Wunused-variable]
    int sensorIndex=p->inputInt[intArgInd++]; 
        ^
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:61:10: warning: variable 'floatParams' set but not used [-Wunused-but-set-variable]
    float floatParams[3];
          ^
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:67:8: warning: variable 'intParams' set but not used [-Wunused-but-set-variable]
    int intParams[2];
        ^
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp: At global scope:
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:119:47: warning: unused parameter 'reservedPointer' [-Wunused-parameter]
 VREP_DLLEXPORT unsigned char v_repStart(void* reservedPointer,int reservedInt)
                                               ^
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:119:67: warning: unused parameter 'reservedInt' [-Wunused-parameter]
 VREP_DLLEXPORT unsigned char v_repStart(void* reservedPointer,int reservedInt)
                                                                   ^
/home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repExtPluginSkeleton.cpp:190:88: warning: unused parameter 'replyData' [-Wunused-parameter]
 VREP_DLLEXPORT void* v_repMessage(int message,int* auxiliaryData,void* customData,int* replyData)
                                                                                        ^
[100%] Building CXX object modules/grl/example/v_repExtPluginSkeleton/CMakeFiles/v_repExtPluginSkeleton.dir/v_repLib.cpp.o
cd /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton && /home/hbr/.linuxbrew/bin/c++   -DBOOST_LOG_DYN_LINK -Dv_repExtPluginSkeleton_EXPORTS -fPIC -Wextra -Wall -std=c++11 -std=c++11 -DNDEBUG -O2                   -O3 -ftree-vectorize -ftree-vectorizer-verbose=0 -march=native -fPIC -I/home/hbr/robonetracker/modules/grl/src -isystem /home/hbr/robonetracker/modules/grl/include/thirdparty/vrep/include -I/home/hbr/robonetracker/modules/grl/include -I/home/hbr/robonetracker/build/include -I/home/hbr/robonetracker/thirdparty -I/home/hbr/robonetracker/include -I/home/hbr/.linuxbrew/include -I/home/hbr/robonetracker/build -I/home/hbr/.linuxbrew/include/eigen3 -I/home/hbr/robonetracker/modules/FRI-Client-SDK_Cpp/include -I/tmp/sawconstraintcontroller20151012-72486-ee97e1/include    -fPIC -fPIC -o CMakeFiles/v_repExtPluginSkeleton.dir/v_repLib.cpp.o -c /home/hbr/robonetracker/modules/grl/example/v_repExtPluginSkeleton/v_repLib.cpp
[100%] Linking CXX shared library ../../../../lib/libv_repExtPluginSkeleton.so
cd /home/hbr/robonetracker/build/modules/grl/example/v_repExtPluginSkeleton && /home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_link_script CMakeFiles/v_repExtPluginSkeleton.dir/link.txt --verbose=1
/home/hbr/.linuxbrew/bin/c++  -fPIC  -fPIC -Wextra -Wall -std=c++11 -std=c++11 -DNDEBUG -O2                   -O3 -ftree-vectorize -ftree-vectorizer-verbose=0 -march=native  -shared -Wl,-soname,libv_repExtPluginSkeleton.so -o ../../../../lib/libv_repExtPluginSkeleton.so CMakeFiles/v_repExtPluginSkeleton.dir/v_repExtPluginSkeleton.cpp.o CMakeFiles/v_repExtPluginSkeleton.dir/v_repLib.cpp.o  -L/home/hbr/robonetracker/build/lib 
make[3]: Leaving directory '/home/hbr/robonetracker/build'
[100%] Built target v_repExtPluginSkeleton
make[2]: Leaving directory '/home/hbr/robonetracker/build'
/home/hbr/.linuxbrew/Cellar/cmake/3.3.2/bin/cmake -E cmake_progress_start /home/hbr/robonetracker/build/CMakeFiles 0
make[1]: Leaving directory '/home/hbr/robonetracker/build'
It is a little concerning that even the plugin skeleton is failing to load!

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

From what I've been reading this may potentially be due to the way the libraries are being set up and loaded via QLibrary. One particular aspect of my set of dependencies is that I'm using different versions of the same libraries used by vrep. One particuar example of this is the versions of libm being used:


+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/vrep
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9644f78000)
+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so
libm.so.6 => /home/hbr/.linuxbrew/lib/libm.so.6 (0x00007f436ccb0000)

I'm going to try the following LD_DEBUG variable to see if I can get additional information:
http://www.bnikolic.co.uk/blog/linux-ld-debug.html

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

I've been able to narrow down the exact cause and produced the stackoverflow question "Linux .so plugin dynamic loading fails due to dependency conflict" to try and resolve it.

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

Here is my modified debugging vrep.sh in case people need it in the future:

Code: Select all

#!/bin/sh
set -e
set -x
set -a

thisscript="$0"
while [ -L "$thisscript" ]; do
        thisscript="`readlink "$thisscript"`"
done

dirname=`dirname "$thisscript"`
if [ $dirname = "." ]; then
        dirname="$PWD"
fi

appname="`basename "$thisscript" | sed 's,\.sh$,,'`"

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$dirname"
export LD_LIBRARY_PATH
ldd "$dirname/libv_repExtGrlInverseKinematics.so"
ldd "$dirname/libv_repExtPluginSkeleton.so"
ldd "$dirname/$appname"
LD_DEBUG=all "$dirname/$appname" "$@"
To log the data I run:

Code: Select all

./vrep.sh >> linkinfo2.txt 2>&1
Haven't figured out how to solve the actual problem, but at least it is completely identified now.
Last edited by ahundt on 03 Nov 2015, 02:15, edited 1 time in total.

ahundt
Posts: 112
Joined: 29 Jan 2015, 04:21

Re: Crashing when loading user compiled plugins on Linux

Post by ahundt »

@copellia,

There are improvements that can be made to how RPATH is set when vrep is built for release. I believe this is the reason LD_LIBRARY_PATH has to be set in vrep.sh. By properly configuring the rpath at the compile step when vrep is created, you will be able to avoid vrep.sh altogether and also help avoid the problems I've encountered here. I'll propose one such solution, but you may want to consider reading up on how RPATH works for a truly correct solution.

First I changed vrep.sh to completely clear LD_LIBRARY_PATH, so it doesn't interfere with what's loading.

Code: Select all

unset LD_LIBRARY_PATH
My first hints towards solving the problem were from this stackoverflow post on rpath following commands from that post that let you see the current rpath:

Code: Select all

objdump -x binary-or-library |grep RPATH

# Maybe an even better way to do it is the following:
readelf -d binary-or-library |head -20

# This second command above also lists the direct dependencies on other libraries followed by rpath.

# On ubuntu 15.04 someone had to use:
objdump -x binary-or-library |grep RUNPATH
The current 3.2.2 release of vrep has a very strange rpath, which I believe is because it may not be explicitly configured when vrep is built for release:

Code: Select all

$ objdump -x vrep |grep RPATH
  RPATH                /home/marc/Qt5.2.0/5.2.0/gcc_64:/home/marc/Qt5.2.0/5.2.0/
To solve the problem in my case I created a symlink from $VREPDIR/lib to where I wanted my libraries to be found in ~/.linuxbrew/lib, then I changed the rpath of the vrep executable with the following commands:

Code: Select all

VREPDIR=/path/to/vrep/executable
cd $VREPDIR
ln -s ~/.linuxbrew/lib $VREPDIR/lib
patchelf --set-rpath '$ORIGIN/lib' vrep
Note that the ld/rpath/patchelf systems understand $ORIGIN to be the directory where the vrep executable is located. Once I've run the above code, I have a new RUNPATH as follows (RPATH vs runpath may be due to version differences?):

Code: Select all

$ objdump -x vrep |grep RUNPATH
  RUNPATH              $ORIGIN/lib
This solution isn't ideal and I'll probably need to fix it up because it is picking up the linuxbrew Qt installation as follows:

Code: Select all

libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007fece8993000)
This may conflict with the API used by V-REP in the Qt shared library provided in the directory alongside vrep, especially as linuxbrew is updated. Nonetheless this solution works and vrep is loading 2 out of 3 .so libraries without crashing! One improvement will be a few minor changes like those outlined below so that the libraries provided with vrep are still loaded.

Actually, the ideal solution for me would be one where vrep loads the system libraries, and the plugin loads the .linuxbrew libraries. I'm not sure that is possible and if it is it may require modifications to the vrep source/build.

This is what I suggest be done for vrep in future releases

I'm not an expert in this, so it may be wide to consult better resources. Searching "properly configuring rpath for a binary distribution" turned up some interesting results. As a side note you may want to consider CMake as a build tool, it makes builds easier and works across platforms.

Anyway, here are my thoughts based on what I've learned:
  • - Create a $VREPDIR/lib directory, and in it include all the .so libraries you provide, as well as symlinks to the expected system library dependencies in /usr/lib.
    - In the step where you compile with gcc pass the -rpath parameter in and the two directories $ORIGIN/lib and $ORIGIN/usr/lib, where users can put their libraries.
    - Alternately you can just pass $ORIGIN and it will load all the libraries in the same folder as the vrep executable.
    - Ultimately, I believe with proper configuration of the RPATH, the vrep.sh script wouldn't be necessary anymore.
It would also be very nice if a Lua function could be provided where we can load libraries with absolute paths, paths relative to the location of the .ttt file, etc. It seems the QLibrary object makes this very easy, and it is the tool you're already using in your code base to load libraries dynamically.

Could you consider changing the way paths are handled and improving the way libraries are dynamically loaded a bit?

Post Reply