Why is ImageMagick within node.js crashing?

I'm using node.js, node-vips and libvips compiled with ImageMagick to convert and resize images. I'm getting segmentation faults and failed assertions when I try and resize more than a couple of images.

I've had so many different crashes I'm not sure where to begin. I started off with libvips 7.26.8, I've also tried 7.30.7. This is with node v0.8.17 compiled from source, on a fairly standard, clean ubuntu box.

#0  0x0000158ac3765c59 in ?? ()
Cannot access memory at address 0x7fffa837ec90

#0  0x0000000000000000 in ?? ()
#1  0x0000000000000000 in ?? ()

node: ../deps/uv/src/unix/stream.c:729: uv__stream_io: Assertion `!!(events & EV_READ) ^ !!(events & EV_WRITE)' failed.
Aborted (core dumped)

#0  0x00007f5ed4df9425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f5ed4dfcb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007f5ed4df20ee in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007f5ed4df2192 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00000000005d1bc8 in uv__stream_io (loop=<optimized out>, w=<optimized out>, events=<optimized out>) at ../deps/uv/src/unix/stream.c:729
#5  0x00000000005c6ac2 in ev_invoke_pending (loop=0xdb34c0 <default_loop_struct>) at ../deps/uv/src/unix/ev/ev.c:2145
#6  0x00000000005c2986 in uv__poll (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:246
#7  uv__run (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:257
#8  0x00000000005c2c60 in uv_run (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:265
#9  0x000000000057d9f7 in node::Start(int, char**) ()
#10 0x00007f5ed4de476d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#11 0x0000000000575245 in _start ()

#0  0x00000000006b13b8 in v8::Object::SetHiddenValue(v8::Handle<v8::String>, v8::Handle<v8::Value>) ()
#1  0x0000000000593f5a in node::SlabAllocator::Allocate(v8::Handle<v8::Object>, unsigned int) ()
#2  0x0000000000591d04 in node::StreamWrap::OnAlloc(uv_handle_s*, unsigned long) ()
#3  0x00000000005d08fb in uv__read (stream=0x1fa7f90) at ../deps/uv/src/unix/stream.c:575
#4  0x00000000005d1a1a in uv__stream_io (loop=<optimized out>, w=<optimized out>, events=<optimized out>) at ../deps/uv/src/unix/stream.c:745
#5  0x00000000005c6ac2 in ev_invoke_pending (loop=0xdb34c0 <default_loop_struct>) at ../deps/uv/src/unix/ev/ev.c:2145
#6  0x00000000005c29df in uv__poll (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:248
#7  uv__run (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:257
#8  0x00000000005c2c60 in uv_run (loop=0xdb27e0 <default_loop_struct>) at ../deps/uv/src/unix/core.c:265
#9  0x000000000057d9f7 in node::Start(int, char**) ()
#10 0x00007f065aa1176d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#11 0x0000000000575245 in _start ()

More often than not I get one of the first two errors – ie, no stack trace. These all occurred while trying to resize 6 or so images – occasionally they all succeed without error, but usually it seg faults after the first one or two have been resized.

How on earth do I go about debugging this?

In the unit test for the node-vips plugin there's a comment that reads:

this test will crash if vips is compiled with imagemagick support because imagemagick crashes when called from libeio

Why is this? Is this still true? I thought ImageMagick was perfectly thread-safe, what about it makes it not safe to be called from libeio/libuv?