Let me start by saying that I know the correct thing to do is upgrade to a newer version of perl, but I request that you trust me on this - right now, upgrade is not an option.

The host OS is FreeBSD 8.0 ( and no, upgrading the OS isn't an option either. )

The problem is that perl sometimes panics when I try to open a UNIX domain socket to communicate with a C program.

main::die_catcher('Assertion ((svtype)((sv)->sv_flags & 0xff)) != 0xff + failed: f...') called at /usr/local/lib/perl5/5.10.1/mach/IO/Handle. +pm line 480 IO::Handle::autoflush('IO::Socket::UNIX=GLOB(0x802a5bff0)', 1) called +at /usr/local/lib/perl5/5.10.1/mach/IO/Socket.pm line 44 IO::Socket::new('IO::Socket::UNIX', 'Peer', '/var/HA/myUNIXDomainSocke +t', 'Type', 1) called at /usr/local/lib/perl5/5.10.1/mach/IO/Socket/U +NIX.pm line 23 IO::Socket::UNIX::new('IO::Socket::UNIX', 'Peer', '/var/HA/myUNIXDomai +nSocket', 'Type', 1) called at /usr/local/lib/perl5/site_perl/5.10.1/ +myLibrary.pm line 290
The offending code is -
my $connection = IO::Socket::UNIX->new( Peer => $uds_path, Type => SOCK_STREAM );

So my question is, "Is anyone familiar with this bug?" I could find very little about it on the web ( mainly http://www.nntp.perl.org/group/perl.perl5.porters/2009/11/msg153316.html ), and nothing in the perl bug database. What I'm really looking for is the conditions that trigger it, as it is a fairly low frequency occurrence, but once it gets triggered, it seems to keep happening. Is it possible that it is triggered by the state of the other side of the socket? ( This seems unlikely, as it looks as though autoflush is set before trying to connect )

Failing controlling the conditions that trigger the bug, is there a reasonable workaround? The one that comes to mind is to open the socket inside of an eval. Your thoughts on the matter will be appreciated.

Edit: OK here is full diag
Assertion ((svtype)((sv)->sv_flags & 0xff)) != 0xff failed: file "sv.c +", line 5400 at /usr/local/lib/perl5/5.10.1/mach/IO/Handle.pm line 48 +0.
--babel17

Update: Solution

So in the end this turned out to be be programmer error. For complicated reasons, and simple ones (like stupidity), I was calling Sys::Syslog->syslog() after syslog had been closed. Strangely enough this all seemed to work fine until syslogd was SIGHUP'd by log rotation, and then things started to go wrong. Presumably something got terribly screwed up in the relationship between perl filehandles and C file descriptors.


In reply to [Solved] Request help for work around for bug in perl 5.10.1 by babel17

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.