Closed nunoguedelha closed 1 year ago
Issue still occurred in commit 2c3aa4b7bf9ea76b95afb0fa6a4ad31b6a2ffe54 of branch main
.
Not reproducible on latest commit of branch main
: 390b246cd628a1aff415d0375d935706f48dd28e.
Checking commit 2c3aa4b7bf9ea76b95afb0fa6a4ad31b6a2ffe54, for making sure future code doesn't reproduce accidentally the code branching or processing causing this issue...
The command node iCubTelemVizServer.js
starts the server but the server crashes right after with a segmentation fault Segmentation fault: 11
.
This is not the same failure reported in this issue description. The log reported in the description was either wrong or obtained while some issue with the IMU port data occurred on the real robot (not reproduced).
We shall analyse here the only failure reproduced so far, i.e. the segmentation fault, which log is listed below.
If we list the running node
processes (ps -ef | grep node
), we can see that the openmctStaticServer
server is still running while the telemetry server iCubTelemVizServer
has stopped, so that was the process to crash ungracefully.
when adding a breakpoint to the line... https://github.com/ami-iit/yarp-openmct/blob/390b246cd628a1aff415d0375d935706f48dd28e/iCubTelemVizServer/openMctServerHandlerParentProc.js#L67 ...then continuing the execution, we get the same error reported in the issue description:
/Users/nunoguedelha/dev/yarp-openmct/iCubTelemVizServer/icubtelemetry.js:282
this.state[id].ori.roll = sensorSample[3][0][0][0];
^
TypeError: Cannot read property '0' of undefined
at ICubTelemetry.parseFromId (/Users/nunoguedelha/dev/yarp-openmct/iCubTelemVizServer/icubtelemetry.js:282:57)
at Object.<anonymous> (/Users/nunoguedelha/dev/yarp-openmct/iCubTelemVizServer/icubtelemetry.js:166:31)
at /Users/nunoguedelha/dev/yarp-openmct/iCubTelemVizServer/iCubTelemVizServer.js:74:56
at /Users/nunoguedelha/dev/yarp-openmct/node_modules/YarpJS/yarp.js:188:13
at callbackTrampoline (internal/async_hooks.js:134:14)
(robotologydeps3) nunoguedelha@iiticublap199 iCubTelemVizServer (main)
I've installed a stack tracer for Node.js, as explained here https://snyk.io/advisor/npm-package/node-segfault-handler#package-footer.
Changes in https://github.com/ami-iit/yarp-openmct/blob/main/iCubTelemVizServer/iCubTelemVizServer.js
/**
* Server http (non secure)
*/
let segfaultHandler = require('node-segfault-handler');
...
// Create the servers
var icubtelemetry = new ICubTelemetry(portInConfig,segfaultHandler);
function ICubTelemetry(portInConfig,segfaultHandler) {
segfaultHandler.registerHandler();
We get the following trace:
{ status: 'OK', message: 'Opem-MCT static server process started.' }
info:Yarp command successfully started...
ICubTelemetry History Server listening on http://192.168.1.70:8081/history
ICubTelemetry Realtime Server listening on ws://192.168.1.70:8081/realtime
Control Console Server listening on http://192.168.1.70:3000
=========== Caught a Segmentation Fault [pid=12043] ===========
-----[ Native Stacktraces ]-----
Cannot unwind stacktraces: Feature disabled / Missing libunwind on your system
---[ V8 JavaScript Stacktraces ]---
at (null) (/Users/nunoguedelha/dev/yarp-openmct/iCubTelemVizServer/iCubTelemVizServer.js:74:67)
at (null) (/Users/nunoguedelha/dev/yarp-openmct/node_modules/YarpJS/yarp.js:188:13)
============================================================
The trace shows that the segfault occurs always here...
https://github.com/ami-iit/yarp-openmct/blob/2c3aa4b7bf9ea76b95afb0fa6a4ad31b6a2ffe54/iCubTelemVizServer/iCubTelemVizServer.js#L73-L74
...when calling processOrDropYarpData
.
by adding a breaking to that line, we can see the systematic sequence leading to the segfault:
We break three times, each time we run bottle.toArray()
in the console in order to check the bottle content. Last run crashes the debugger. This behaviour is systematic, which is good news.
The bottle with the left leg joint state data is causing the problem here (id = 'sens.leftLegJointState'
).
Analysing...
For the second call, with id = 'sens.headIMU'
(M.A.S. sensor data),...
bottle.toString()
returns (((-0.240112648394806865726 0.256409150712710476316 1.25491568355236471355) 4336.35999999999967258)) (((-0.152372687054658478845 -0.0560934592355309263878 -9.73042375287977989728) 4336.35999999999967258)) (((0.0 0.0 0.0) 4336.35999999999967258)) (((0.000133744890740640628643 -0.00548904149557477138294 2.25436842049552410572) 4336.35999999999967258)) () () () () () ()
bottle.toArray()
returns Array(10) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
.bottle.toArray()
should return the same content instead of zeros. So, for nested bottles, either we get a wrong result or we get a segmentation fault. This is a YarpJS bug..
Moving the issue to YarpJS repo.
Side note: this problem occurred to @S-Dafarra a few times on his machine even when running npm start
. If I remember correctly:
We had no clue on what was happening! We reproduced the issue here.
Moved issue to https://github.com/robotology/yarp.js/issues/49.
Refer to [Issue 1] in the issue recap below:
_Originally posted by @nunoguedelha in https://github.com/ami-iit/component_ANA-Avatar-XPRIZE/issues/760#issuecomment-1266616475_