Mantis - Resin
Viewing Issue Advanced Details
5627 major always 01-03-14 13:16 09-12-14 10:50
bean  
ferg  
normal  
closed 4.0.38  
fixed  
none    
none 4.0.41  
0005627: data corruption due to improper handing of EINTR
several JNI methods do not handle an errno of EINTR. The result is corrupted data.

EINTR is the status return of a syscall that was interrupted in order to deliver a signal to the thread. In general, the user process should just restart the syscall. The problem is most likely to occur when resin is sitting on a recv() waiting to get data and the recv syscall gets interrupted by a signal.

The bad methods are:
common/streams.c: std_read(), std_write(), cse_fill_buffer()
resin_os/std.c: std_read(), std_read_nonblock(), std_write(), std_write_nonblock()
(1) The Azul JVM, Zing, can sometimes have a high signal rate, which has then hit this problem.

(2) I've uploaded a fixed version of std.c, with the code ifdef'd by #ifdef FIX_EINTR, to illustrate the correct behavior.

 std.c [^] (11,818 bytes) 01-03-14 13:16
 std.c.2 [^] (11,855 bytes) 01-15-14 08:30

Notes
(0006389)
bean   
01-15-14 08:32   
I found a typo in std.c after uploading it. The next file, std.c.2, has the typo fixed as well as identifying on other place where EINTR was not correctly handled.