Issue #3005 has been updated by Takehiro Kubo.


The issue will be fixed the following patch.

=======================================================
--- io.c~	2009-08-09 00:34:48.000000000 +0900
+++ io.c	2010-04-09 00:37:35.000000000 +0900
@@ -496,6 +496,7 @@
 
 struct io_internal_struct {
     int fd;
+    int saved_errno;
     void *buf;
     size_t capa;
 };
@@ -504,36 +505,46 @@
 internal_read_func(void *ptr)
 {
     struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
-    return read(iis->fd, iis->buf, iis->capa);
+    int ret = read(iis->fd, iis->buf, iis->capa);
+    iis->saved_errno = errno;
+    return ret;
 }
 
 static VALUE
 internal_write_func(void *ptr)
 {
     struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
-    return write(iis->fd, iis->buf, iis->capa);
+    int ret = write(iis->fd, iis->buf, iis->capa);
+    iis->saved_errno = errno;
+    return ret;
 }
 
 static int
 rb_read_internal(int fd, void *buf, size_t count)
 {
     struct io_internal_struct iis;
+    int ret;
     iis.fd = fd;
     iis.buf = buf;
     iis.capa = count;
 
-    return rb_thread_blocking_region(internal_read_func, &iis, RUBY_UBF_IO, 0);
+    ret = rb_thread_blocking_region(internal_read_func, &iis, RUBY_UBF_IO, 0);
+    errno = iis.saved_errno;
+    return ret;
 }
 
 static int
 rb_write_internal(int fd, void *buf, size_t count)
 {
     struct io_internal_struct iis;
+    int ret;
     iis.fd = fd;
     iis.buf = buf;
     iis.capa = count;
 
-    return rb_thread_blocking_region(internal_write_func, &iis, RUBY_UBF_IO, 0);
+    ret = rb_thread_blocking_region(internal_write_func, &iis, RUBY_UBF_IO, 0);
+    errno = iis.saved_errno;
+    return ret;
 }
 
 static long
=======================================================

> Ok, I have made a reduced version of the script that always reproduces the core dumps.
> The problem must be related with the oci8, because if I comment out the lines 23 and 25 it does not generate cores.

The problem is caused by resetting errno in the signal handler. It can be reproduced by replacing line 23 and 25 with Math.log10(10), which set errno to zero.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3005

----------------------------------------
http://redmine.ruby-lang.org