Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

djberg96 (2603)

djberg96
  (email not shown publicly)

Journal of djberg96 (2603)

Wednesday July 16, 2003
12:54 PM

File Descriptors (or, "Giant Sucking Sound")

[ #13486 ]
A co-worker and I traced down an incredibly annoying bug today. Our client/server app would just seem to hang after a while. Oh, the process was still running and there was nothing in the error log, but it just wouldn't return anything any more. At first, we assumed the problem was with the server itself, so there was lots of debugging going on there. To make matters more interesting, this only seemed to happen on Linux.

We finally narrowed it down to a file descriptor issue - the server was sucking them all up. Eventually, it would use them all and then it would hang. More debugging of the server ensued.

We *finally* narrowed it down to sys-proctable, a C extension based on Dan Urist's Proc::ProcessTable. So, somewhere I managed to eff up my C code so that it's not letting go of a filehandle somewhere. My attempts to shift the blame to Dan failed - his code does NOT suffer from the same bug (I checked).

The really weird thing is that everything seemed be ok about 2 weeks ago. Why wasn't it failing before? I have no frikkin clue.

It's that kinda stuff that gets my stomach in knots. Now I feel like a complete knucklehead for stressing over this for the last week or so.

UPDATE: Checking the C source I see that I have 4 calls to open() and 3 calls to close(). That could be a problem...YA THINK? All better now. :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • How about ulimit -a
    On my linux box, I get

    core file size (blocks, -c) 0
    data seg size (kbytes, -d) unlimited
    file size (blocks, -f) unlimited
    max locked memory (kbytes, -l) unlimited
    max memory size (kbytes, -m) unlimited
    open files (-n) 1024
    pipe size (512 bytes, -p) 8
    stack size (kbytes, -s) 8192
    cpu time (seconds, -t) unlimited
    max user processes (-u) 2048
    virtual memory (kbytes, -v) unlimited
    • Nope - it was definitely a bug in my code. I just nailed it. Fortunately it was a simple procedure. It went something like this (imagine me counting this stuff manually):

      Number of "open" calls...1..2..3..4.
      Number of "close" calls...1..2..3...hmmmm..

      Five minutes later I had it fixed and created a little test with an FD counter to make sure. All better now. :)