From: Eric Hodel Date: 2008-05-28T13:33:30+09:00 Subject: Re: 1.8.6, jemalloc, sock.close problem On May 27, 2008, at 14:16 PM, Christopher Thompson wrote: > Warning: This message is probably only peripherally related to Ruby! > > In order to reduce the amount of memory that Ruby uses, we are > trying to get Mozilla's (actually, FreeBSD's) jemalloc working in > Ruby 1.8.6. > > Everything seems to work well EXCEPT that occasionally, a call to > close a socket fails. I can catch an Errno:EINVAL but for the life > of me, I cannot figure out what could cause this. It only happens > occasionally. I have not been able to find any other problems. close(2) itself doesn't have EINVAL listed as one of its error conditions. Which one is actually raising (the exception message should say)? This will help narrow it down to a specific piece of code. > I suspect some sort of memory issue with jemalloc but running > everything under valgrind shows no likely suspects. I've tried > debugging with Ruby 1.8.6-p114 and with 1.8.7-preview4, both show > the same problem. Have you tried any of the malloc flags? A and J in particular may be helpful. http://www.freebsd.org/cgi/man.cgi?query=malloc&apropos=0&sektion=0&manpath=FreeBSD+7.0-RELEASE&format=html Can you reproduce this on FreeBSD 7? > If anyone has any ideas for avenues to debug this, I'd love to hear > them. I can't actually figure out the line of code in Ruby that's > sending back the Errno:EINVAL; I've only been working with the Ruby > code base for a short time. And the fact that it only happens > occasionally makes it really difficult to debug. rb_sys_fail() raises one a SystemCallError subclass based on the value of errno. Typically a SystemCallError contains the name of the libc function that set errno in the message.