Title: Compaq Perl 5.6.1 crashing in "close()"

Hi,

We are upgrading our systems from VMS 7.2-1 to VMS 7.3-1, as well as from an in-house build of Perl 5.005_03 to the Compaq Perl 5.6.1 binary distribution.

For some reason one (and only one) of our scripts is causing an ACCVIO in the perl interpreter. I have isolated it to a single line, which is a call to "close ($fh)", where "$fh" is a file handle which has been bound to a socket.  The crash is very intermittent, and I cannot reproduce it with a simple test program. However, the code roughly does something like this:

#####################################################################
use Filehandle;
use Socket qw( SOCK_STREAM PF_INET inet_aton sockaddr_in inet_ntoa INADDR_ANY);

$handle = FileHandle->new();
socket($handle, &PF_INET(), &SOCK_STREAM(), getprotobyname('tcp'));
bind($handle, sockaddr_in(0, INADDR_ANY)) || die "Could not bind\n";
$saddr = sockaddr_in(1984, inet_aton("op1t301gwy.opf.swissbank.com"));

$connected = 0;

# Use an alarm inside "eval" to avoid blocking.
eval {
        $SIG{'ALRM'} = sub { die "Timed out" };
        alarm(1);

        if(connect($handle, $saddr) ) {
            $connected = 1;
        }
        alarm(0);
    };
    alarm(0);

    if (! $connected) {

        print "Connect failed!\n";
        close $handle;   # ACCVIO happens right here!

} else {
        print "Connected successfully!\n";
        select( undef, undef, undef, 0.5 );
        close( $handle );
        select( undef, undef, undef, 0.1 );
}
#####################################################################

Does anyone see anything horribly wrong or dangerous with this? To be precise, the code which is actually failing is a perl module which does (roughly) the above, and it has 1 file handle per instantiation, allocated in the constructor. The failure seems to occur only when the connection times out and it hits the "close $handle;" statement -- but not consistenty.

Thanks and regards,

David Hansen
UBS Warburg Switzerland


Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

Reply via email to