Hello monks. I've run into a problem with perl's accept() function, as called by IO::Socket.pm. Occasionally, a process dies just after accept() is called, such that accept doesn't even return, it just kills the process. I tried putting the call to accept() in an eval so I could catch the error in $@, but no luck, the process still blows up.

While I'd love to supply you with some code to reproduce the problem, I can't, since it's spread through several libs and executables. However, I can show you the offending code, and some run-time info. From IO::Socket, with some debug messages added by me:

printf "PID $$: IO::Socket calling accept(%s, %s)\n", $new, $sock; $peer = accept($new,$sock); printf "PID $$: IO::Socket accept() call returned\n"; return unless $peer;

A successful call:

PID 18943: IO::Socket calling accept(IO::Socket::INET=GLOB(0x833803c), IO::Socket::INET=GLOB(0x879808c))
PID 18943: IO::Socket accept() call returned

An unsuccessful call (with message from SIG{CHLD} handler):

PID 18943: IO::Socket calling accept(IO::Socket::INET=GLOB(0x886d064), IO::Socket::INET=GLOB(0x879808c))
Reaped PID 18943, exit status 14

The script I'm running spawns 3 child processes, which communicate using IO::Socket. The process that eventually dies is doing heavy computing and lots of evals (it's a constraint solver), and, disturbingly, the number of debug messages conditionally compiled in (via constants) does cause variance in the number of messages accepted before it dies. We have tried isolating that process and running it stand-alone, while "stubbing" the other processes by feeding the same input manually, but the problem goes away. The problem comes and goes, but once we get a failing command line it does fail every time, so we can reproduce it.

I should also mention some other potential "issues" with ths code. We see a few "Deep recursion on subroutine blahblah" warnings, as well as some "Use of uninitialized value in bitwise and (&)" warnings, in the code run by this process. However, it has worked many times with these warnings.

I'm running perl 5.8.5 on hosttype "Linux 2.4.9-45lxset34smp GenuineIntel Intel_2791 i686". I tried looking up accept bugs, but the perlbug site won't let me log in (or create a new account), so sorry if this is a known issue. Thanks for any help!


In reply to accept() dies? by beemshake

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.