perl hangs after receiving signal

J

Jeremy Slade

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
 
A

Anno Siegel

Jeremy Slade said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top