janestreet / async_unix

Jane Street Capital's asynchronous execution library (unix)
MIT License
33 stars 21 forks source link

Reading Deferreds From Multi-Process Pipe Causes Segmentation Fault #11

Closed craig-riecke closed 8 years ago

craig-riecke commented 8 years ago

We ran across a problem where we were sending a Deferred over a TCP socket-backed Pipe between two processes. The write worked OK, but the read on the other end of the pipe caused a Segmentation Fault.

I'm 90% convinced this should never actually work. Sending a Deferred and expecting the other end to know how to resolve it seems too much to ask. But it shouldn't seg fault either.

I can construct a simple test case, if needed, but it might take a few days.

yminsky commented 8 years ago

How are you doing this? Using bin-io? Marshal? I don't know why it would segfault, but marshal is an unsafe mechanism if you get the types wrong for sure, and I kind of think that using it on Deferreds should void the warranty....

craig-riecke commented 8 years ago

We're using Reader.read_marshal. I took a shallow look with GDB, and found:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000dfc1e4 in camlAsync_kernel__Ivar0__fun_3964 () at src/ivar0.ml:277
277     src/ivar0.ml: No such file or directory.
(gdb)

I guess we were passing an Ivar? Ugggh, we definitely didn't think it through. Still, maybe a segfault is a little overpunishment?

ghost commented 8 years ago

Well, marshal is unsafe so there is not much we can do in async itself. Did you try using bin_prot instead of marshal? At least it definitely won't make your application segfault

yminsky commented 8 years ago

Yeah, Marshal should basically be excised from the language. I recommend you avoid it entirely. I don't think there's anything for us to do here.