perl hangs after receiving signal

Discussion in 'Perl Misc' started by Jeremy Slade, Apr 1, 2005.

  1. Jeremy Slade

    Jeremy Slade Guest

    I have a script running in perl 5.6.1 on a debian sarge system (kernel
    2.6.8).

    On occasion, the perl interpreter just hangs. I have been able to
    attach to the process with gdb to get a stack trace, and unfortunately
    it is not always the same. But there does seem to be some consistency.
    The last frame of the stack is always pthread_setcanceltype() from
    libc.so.6. Farther down the stack there is almost always
    Perl_signalhandler. Here's an example stack trace:

    #0 0x4014b7a1 in pthread_setcanceltype () from /lib/tls/libc.so.6
    #1 0x4019a940 in __after_morecore_hook () from /lib/tls/libc.so.6
    #2 0x40199fcc in ?? () from /lib/tls/libc.so.6
    #3 0x00000011 in ?? ()
    #4 0x400d9d53 in posix_memalign () from /lib/tls/libc.so.6
    #5 0x40300010 in ?? ()
    #6 0x40300490 in ?? ()
    #7 0x0847f15c in ?? ()
    #8 0x0847f15c in ?? ()
    #9 0x0849fe00 in ?? ()
    #10 0x080a4ac8 in Perl_sv_clear ()
    #11 0x080a4f0b in Perl_sv_free ()
    #12 0x080aef69 in Perl_pp_vec ()
    #13 0x08098f98 in Perl_runops_standard ()
    #14 0x0805cbca in perl_call_sv ()
    #15 0x0805cb0a in perl_call_sv ()
    #16 0x08095247 in Perl_sighandler ()
    #17 <signal handler called>
    #18 0x400d62a8 in free () from /lib/tls/libc.so.6
    #19 0x4019a940 in __after_morecore_hook () from /lib/tls/libc.so.6
    #20 0x084e39e8 in ?? ()
    #21 0x0870fc10 in ?? ()
    #22 0x0870fc10 in ?? ()
    #23 0xbffffb70 in ?? ()
    #24 0x08097b43 in Perl_av_undef ()
    #25 0x080a4b0f in Perl_sv_clear ()
    #26 0x080a4f0b in Perl_sv_free ()
    #27 0x0807ff75 in Perl_cv_undef ()
    #28 0x080a4b4c in Perl_sv_clear ()
    #29 0x080a4f0b in Perl_sv_free ()
    #30 0x080b680a in Perl_free_tmps ()
    #31 0x080994b1 in Perl_pp_unstack ()
    #32 0x08098f98 in Perl_runops_standard ()
    #33 0x0805c2df in perl_run ()
    #34 0x0805c15a in perl_run ()
    #35 0x08059c3a in main ()


    I have tried the same script on debian stable systems (same perl 5.6.1
    binary, however), and it seems to work much better, I don't ever see
    this problem.

    Since this call to pthread_setcanceltype happens way down inside other
    function calls, I suspect this is not at all a perl problem, but rather
    a linux or libc problem. But I am hoping that someone can offer some
    help in determining why this hangs and what I might be able to do about it.

    Thanks,
    Jeremy
    Jeremy Slade, Apr 1, 2005
    #1
    1. Advertising

  2. Jeremy Slade

    Anno Siegel Guest

    Jeremy Slade <> wrote in comp.lang.perl.misc:
    > I have a script running in perl 5.6.1 on a debian sarge system (kernel

    ^^^^^
    > 2.6.8).


    Perl signal handling was unsafe before 5.8.0. In particular, if a program
    was interrupted during a memory allocation, and the signal handler started
    off another memory allocation (can easily happen in inconspicuous code),
    that usually meant a segfault.

    > On occasion, the perl interpreter just hangs. I have been able to


    I don't know why it hangs, but when you re-enter non-re-entrant code
    basically anything can happen.

    > Perl_signalhandler. Here's an example stack trace:


    [stack trace much shortened, missing parts indicated]

    ....
    > #4 0x400d9d53 in posix_memalign () from /lib/tls/libc.so.6

    ....
    > #16 0x08095247 in Perl_sighandler ()
    > #17 <signal handler called>
    > #18 0x400d62a8 in free () from /lib/tls/libc.so.6

    ....

    The signal arrives during free(), a memory (de-)allocation. The memory
    heap may be inconsistent. In the signal handler, something called
    posix_memalign() is called. I don't know what it is, but it sounds much
    like something that might be sensitive to an inconsistent heap. That
    seems to match the theory pretty well.

    Anno
    Anno Siegel, Apr 1, 2005
    #2
    1. Advertising

  3. Jeremy Slade

    Jeremy Slade Guest

    Ah, thanks for the info. Yet one more reason I need to move to 5.8.

    Anno Siegel wrote:
    > Jeremy Slade <> wrote in comp.lang.perl.misc:
    >
    >>I have a script running in perl 5.6.1 on a debian sarge system (kernel

    >
    > ^^^^^
    >
    >>2.6.8).

    >
    >
    > Perl signal handling was unsafe before 5.8.0. In particular, if a program
    > was interrupted during a memory allocation, and the signal handler started
    > off another memory allocation (can easily happen in inconspicuous code),
    > that usually meant a segfault.
    Jeremy Slade, Apr 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Pronath
    Replies:
    1
    Views:
    1,158
    Diez B. Roggisch
    Jan 3, 2005
  2. Replies:
    2
    Views:
    722
    mlimber
    Nov 4, 2005
  3. giohappy
    Replies:
    5
    Views:
    1,829
    giohappy
    Apr 15, 2009
  4. Tim Shadel

    Gem hangs => TCPSocket.write hangs

    Tim Shadel, Jul 23, 2005, in forum: Ruby
    Replies:
    1
    Views:
    381
    Ville Mattila
    Jul 24, 2005
  5. Collin Vandyck
    Replies:
    1
    Views:
    127
    Collin Vandyck
    Sep 12, 2007
Loading...

Share This Page