joyent/libuv — Issue #287: Spawning 100+ processes causes segfault in libev
Author: chriso
Created: 2012-01-07 06:50:38+00:00
State: open

Dup of [node #2481](https://github.com/joyent/node/issues/2481) but posted here as it appears to be a libev issue.

**test.js**

```javascript
var child = require('child_process');
for (var i = 0; i < 100; i++) {
child.spawn('echo');
}
```

Running this on OS X Lion:

```bash
~ $ node test.js
Segmentation fault: 11
```

Here's the GDB output:

```
~ $ gdb /tmp/node-v0.6.7/out/Release/node
GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul 1 10:50:06 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ........... done

(gdb) run test.js
Starting program: /private/tmp/node-v0.6.7/out/Release/node test.js
Reading symbols for shared libraries ++++++++++.......................................................................................................................... done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000000103dbd4b8
0x000000010026a8c9 in clear_pending (loop=0x1004ca3c0, w=0x100720b58) at ev.c:2609
2609	pendings [ABSPRI (w)][w->pending - 1].w = (W)&pending_w;
```