| Summary: | Valgrind memory debugging for nodejs using child process failed on MacOS | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Nazar Hussain <nazarhussain> |
| Component: | memcheck | Assignee: | Paul Floyd <pjfloyd> |
| Status: | RESOLVED WAITINGFORINFO | ||
| Severity: | normal | CC: | pjfloyd, rhyskidd |
| Priority: | NOR | ||
| Version First Reported In: | 3.14 SVN | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | macOS | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
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. Which version of macOS was this for? Closing this without any further info. |
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.