develooper Front page | perl.perl5.porters | Postings from November 2000

[ID 20001107.003] Segmentation fault with sockets applications

Thread Next
From:
Fulko Hew
Date:
November 7, 2000 10:32
Subject:
[ID 20001107.003] Segmentation fault with sockets applications
Message ID:
200011071709.MAA21815@fulko3.wecan.com

This is a bug report for perl from fulko@wecan.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.


-----------------------------------------------------------------
[Please enter your report here]

I have written some code that performs socket operations.
Along with the code, I have a test harness for both the server side
as well as the client side.

Unfortunately, I cannot successfully generate a simple test case
to demonstrate the problem.  The full test suite and code, although
fairly simple is propriatary, and I cannot post it, although I can
mail it explicitly to someone for testing purposes.

An additional problem is that perl only core dumps on slow ( < 200Mhz)
machines running Linux.  I have also tested the scenerio with the
client and server on different boxes, only to have it work, and
on faster CPU's and it also works. I have not seen a failure when
running my code in 5.004_004 on SCO OpenServer at 233Mhz or
a 5.005_03 on a Dell machine at 600Mhz with an unknown RedHat
distribution pre-installed (uname -r ==> 2.2.14-6.1.1).

I have tested my code on both perl 5.6.0 and 5.005_003 and both fail
on that Linux (RedHat 6.2) machine.

(I have attempted to get a stack trace via xxgdb, but have been
unable to do so, due to a lack of experience with gdb.  sorry
someone will have to tell me how to do it.)



The primary error I see is:

    "Segmentation fault (core dumped)"

although I have also seen:

    "Attempt to free unreferenced scalar at ./blob line 615."
and

    "Attempt to free temp prematurely"

line 615 is:

        while ($client = $server->accept()) {

I suspect that the core dump is also at/near that location.
Any attempt to put print statements around that code appears
to change the system timing in such a manner that it will never
fail.  Adding a sleep(1) or the select() as shown below
makes the system "not fail" but with the unfortunate side effect
of the extra delay.

The code snippet that fails is:

   while (1) {
        while ($client = $server->accept()) {
            unless ($client) {
                print "accept failed: $!\n";
                next;
            }
            next if ($pid = fork);                              # go look for another caller
            if (!defined($pid)) {
                print "child forking failed: $!\n";
            } else {                                            # child (connection processing) continues here
                $SIG{PIPE} = \&closer;                          # install a socket closure detector
                $self->{_socket} = $client;
                my ($rp, $ra) = unpack_sockaddr_in(getpeername($client));
                ($self->{_remote_host}, $self->{_remote_port}) = (inet_ntoa($ra), $rp);
                close $server;                                  # child doesn't need this socket anymore

                &$server_fnc($self, @advertizers);              # call the users function to do their work
                exit;
            }
        } continue {
#            select(undef, undef, undef, 1);		# INSERT THIS LINE TO GUARANTEE IT WON'T CORE DUMP !!!!!
            close $client;                                      # parent doesn't need this socket anymore
        }
    }




[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=critical
---
Site configuration information for perl v5.6.0:

Configured by root at Thu Nov  2 12:33:51 EST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.12-20, archname=i586-linux
    uname='linux fulko3 2.2.12-20 #1 mon sep 27 10:25:54 edt 1999 i586 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.2.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/i586-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/home/fulko
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=en_US
    LD_LIBRARY_PATH=:/usr/local/lib:/usr/local/lib
    LOGDIR (unset)
    PATH=/usr/local/jdk1.2.2/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/fulko/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About