#1093776 perl: occasionally hangs and no longer responds to trapped signals

Package:
perl
Source:
perl
Description:
Larry Wall's Practical Extraction and Report Language
Submitter:
Vincent Lefevre
Date:
2025-03-16 01:12:02 UTC
Severity:
normal
#1093776#5
Date:
2025-01-22 15:39:04 UTC
From:
To:
I have a Perl script that hung twice. Some signals are trapped
in the following way:

$SIG{'INT'} = sub
  { maplepid and quitmaple;
    $SIG{'PIPE'} = 'DEFAULT';
    warn "Interrupt\n";
    exit; };
$SIG{'QUIT'} = sub
  { maplepid and quitmaple;
    $SIG{'PIPE'} = 'DEFAULT';
    warn "Quit\n";
    $SIG{'QUIT'} = 'DEFAULT';
    kill 'QUIT', $$; };

While strace shows that perl received these signals, perl doesn't
output anything (note: maplepid returns undef) and these signals
are completely ignored.

Note that this issue is rather rare: the script is running
continuously, the this issue occurred twice in several months.

#1093776#10
Date:
2025-03-16 01:09:36 UTC
From:
To:
As this occurred again... The backtrace obtained with gdb on the
running process for the main thread:

#0  __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0,
    op=393, expected=0, futex_word=0x7ff580000c74)
    at ./nptl/futex-internal.c:57
#1  __futex_abstimed_wait_common (futex_word=futex_word@entry=0x7ff580000c74,
    expected=expected@entry=0, clockid=clockid@entry=0,
    abstime=abstime@entry=0x0, private=private@entry=0,
    cancel=cancel@entry=true) at ./nptl/futex-internal.c:87
#2  0x00007ff584db8f7b in __GI___futex_abstimed_wait_cancelable64 (
    futex_word=futex_word@entry=0x7ff580000c74, expected=expected@entry=0,
    clockid=clockid@entry=0, abstime=abstime@entry=0x0,
    private=private@entry=0) at ./nptl/futex-internal.c:139
#3  0x00007ff584dbb5d8 in __pthread_cond_wait_common (abstime=0x0, clockid=0,
    mutex=0x7ff580000c10, cond=0x7ff580000c48)
    at ./nptl/pthread_cond_wait.c:503
#4  ___pthread_cond_wait (cond=0x7ff580000c48, mutex=0x7ff580000c10)
    at ./nptl/pthread_cond_wait.c:618
#5  0x00007ff584ac8ac3 in ?? ()
   from /usr/lib/x86_64-linux-gnu/perl/5.36/auto/threads/shared/shared.so
#6  0x0000560ec5063377 in Perl_pp_lock ()
#7  0x0000560ec5022f26 in Perl_runops_standard ()
#8  0x0000560ec4f81779 in perl_run ()
#9  0x0000560ec4f534b2 in main ()

This is a script with worker threads, and there is nothing that
could make the main thread hang. In particular, according to
logging messages, no locks are involved here. The only thing
related to threading in this part of the code is

  $queue->enqueue($_[0]);

where $queue has been created with

  my $queue = Thread::Queue->new();

(note that there is no limit of the size of the queue, and even
if there had been one, this should not have been an issue).

So perhaps there's something wrong in the Thread::Queue
implementation.