## Vrep crashes with seg falut signal 11 when run a C++ plugin

Report crashes, strange behaviour, or apparent bugs
potatolige
Posts: 10
Joined: 09 Apr 2018, 10:31

### Vrep crashes with seg falut signal 11 when run a C++ plugin

Hi,

I am using vrep c++ plugin in robot machine learning stuff and it always crashes randomly after thousands of training episodes. My system is Ubuntu 18.04 and my vrep is latest version.

And I googled a little bit and found a way to write a seg fault handler to trace where the crash happened and here is the output:

Code: Select all

Error: signal 11:
/is/ei/gli/Documents/VREP/libv_repExtTRTT.so(_ZN9Utilities24SegmentationFaultHandlerEi+0x34)[0x7fffcfd82bf3]
/lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7ffff6ceef20]
liblua5.1.so(+0xda1a)[0x7ffff7ed8a1a]
liblua5.1.so(+0xdaa6)[0x7ffff7ed8aa6]
liblua5.1.so(+0xddd6)[0x7ffff7ed8dd6]
liblua5.1.so(+0xe18f)[0x7ffff7ed918f]
liblua5.1.so(+0xbd77)[0x7ffff7ed6d77]
liblua5.1.so(+0xbdf5)[0x7ffff7ed6df5]
liblua5.1.so(lua_pcall+0x55)[0x7ffff7ed2d35]
libv_rep.so(_ZN16CLuaScriptObject9_luaPCallEPviiiPKc+0xd8)[0x7ffff2d84738]
free(): invalid pointer
libv_rep.so(_ZN16CLuaScriptObject30_runScriptOrCallScriptFunctionEiPK15CInterfaceStackPS0_PNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPbSB_SB_+0x18e)[0x7ffff2d85fee]
libv_rep.so(_ZN16CLuaScriptObject17_runMainScriptNowEiPK15CInterfaceStackPS0_Pb+0x94)[0x7ffff2d86f24]
libv_rep.so(_ZN16CLuaScriptObject14_runMainScriptEiPK15CInterfaceStackPS0_Pb+0x176)[0x7ffff2d876c6]
libv_rep.so(_ZN16CLuaScriptObject13runMainScriptEiPK15CInterfaceStackPS0_Pb+0x101)[0x7ffff2d87891]
libv_rep.so(_Z28simHandleMainScript_internalv+0x1c4)[0x7ffff2e28b34]
/is/ei/gli/Documents/VREP/vrep[0x4024d2]

The output pointed out that a free() function failed in these two libraries(liblua5.1.so, libv_rep.so) caused this crash. But it didn't tell me if I made something wrong in my own library(libv_repExtTRTT.so)

And to be more specific, I write all my code in C++ and generate this external library running in vrep but I didn't have any lua code in my simulation. Another thing to mention is that I use c++ 11 and all the data structure in my code is from standard library, such as std::vector, std::array or std::unique_ptr, std::shared_ptr etc.

I cannot easily say that this crash is caused by Vrep, because maybe I made some mistakes when I call the API functions. Therefore I would like to ask for some suggestion to debug.

FItz

coppelia
Posts: 7587
Joined: 14 Dec 2012, 00:25

### Re: Vrep crashes with seg falut signal 11 when run a C++ plugin

Hello,

from the output the crash happens in your plugin, for whatever reason. Try to see where in the plugin exactly. If you can't use a debugger, try first with simple print statements. Check also if you might have a memory leak.

Cheers

potatolige
Posts: 10
Joined: 09 Apr 2018, 10:31

### Re: Vrep crashes with seg falut signal 11 when run a C++ plugin

Hi,

I am using gdb as a debugger and git as version control tool, but the debugger could only tell me that I got a "free() invalid pointer" bug from the two libraries(liblua5.1.so, libv_rep.so). And as I mentioned before, I am using modern c++, so there is no "free(), malloc(), new, delete and raw pointer" stuff in my code at all.

And these days I carefully compare my code with my old code, which worked quite good in before, but I stiill cannot debug my new code. Then I realize that I also modified something in my Vrep scene(not too much stuff). So I run my new code in the old scene and it works without error.

So, I can say that the bug is coming from the new scene itself. But it is quite hard for me to find where the bug is and why it is a bug. Some exact details of how the modification was done is forgotten. And after I modify the old scene and get a new scene again, I cannot reproduce this bug anymore.

I don't know if I can still do something to help you find out this bug and improve your product. If there is, please let me know :D/

Thank you!
Fitz

potatolige
Posts: 10
Joined: 09 Apr 2018, 10:31

### Re: Vrep crashes with seg falut signal 11 when run a C++ plugin

Hi,

Last night I run the simulation overnight and the same problems happened again after 30 hours in the simulation :(