develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #4619] Segmentation fault with sockets applications

Thread Previous
From:
James E Keenan via RT
Date:
June 28, 2012 13:28
Subject:
[perl #4619] Segmentation fault with sockets applications
Message ID:
rt-3.6.HEAD-28836-1340915299-1419.4619-15-0@perl.org
On Tue Nov 07 02:32:08 2000, fulko@fulko3.wecan.com wrote:
> 
> 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
>         }
>     }
> 
> 
> 

I recognized the name of the original poster as a long-time member of
the Toronto Perlmongers and wrote to him off-list at a more up-to-date
email address than that in the OP.  Fulko Hew wrote back:

"I can't reproduce the problem anymore.  Either because the setup isn't
the same, or the problem has gone away.  In either case, we can close
the ticket with 'cannot reproduce'."

Closing ticket.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: stalled
https://rt.perl.org:443/rt3/Ticket/Display.html?id=4619

Thread Previous


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