I am trying to debug a nodejs script which has dependencies on native bindings. That script also involves forking a child process. I am using valgrind to debug the memory issues with following options: ``` valgrind --leak-check=summary --show-leak-kinds=all --trace-children=yes --verbose node app.js ``` It only works if I set `--trace-children=no`, otherwise always failed. I created following sample script to test the scenario and it seems valgrind does not work debugging child process running in node. ``` // main.js var cp = require('child_process'); var child = cp.fork('./worker'); child.on('message', function(m) { // Receive results from child process console.log('received: ' + m); }); // Send child process some work child.send('Please up-case this string'); ``` and ``` worker.js process.on('message', function(m) { // Do work (in this case just up-case the string m = m.toUpperCase(); // Pass results back to parent process process.send(m.toUpperCase(m)); }); ``` And `valgrind` always failed with following error: ``` ==10401== execve(0x1048a3150(/bin/bash), 0x1048a3638, 0x1048a3658) failed, errno 2 ==10401== EXEC FAILED: I can't recover from execve() failing, so I'm dying. ==10401== Add more stringent tests in PRE(sys_execve), or work out how to recover. ``` This happens only on MacOS, I tried it on Ubuntu and its working fine.
I think your code may have a subtle bug in it. To test this can you run in a Terminal window within the relevant testing folder: // How does the program loader find the JS interpreter? $ ./worker I believe your main.js should be changed as follows: > - var child = cp.fork('./worker'); > + var child = cp.fork('worker.js');
Any further feedback Nazar? Will close this report unless able to establish this is indeed a Valgrind bug, not an application bug.