This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/17314] New: Any thread created by Python must block SIGCHLD


https://sourceware.org/bugzilla/show_bug.cgi?id=17314

            Bug ID: 17314
           Summary: Any thread created by Python must block SIGCHLD
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

This is related to PR 17247, but in this case I think a simple doc improvement
is what's needed, modulo going with something more robust (if possible):
An alternate solution would be to have linux-nat.c:sigchld_handler detect, if
possible (can one obtain the thread id in an async-safe way?  seems like gettid
should be async-safe) that the wrong thread has received the signal and cope.

Basically, gdb is the only thread that can receive SIGCHLDs.
Otherwise gdb will hang in the sigsuspend calls in linux-nat.c.

For future debugging sake, IWBN to print the thread id in
linux-nat.c:sigchld_handler.

Repro:

---foo.py---
import thread
import time

def forever():
  while True:
    time.sleep(1)

def start_background_thread():
  thread.start_new_thread(forever, ())
---

bash$ make run
(gdb) source foo.py
(gdb) py start_background_thread()
(gdb) file testsuite/gdb.threads/print-threads
(gdb) r
...
[New Thread 0x2aaaab7a3700 (LWP 14472)]
Print 1, thread 0
[New Thread 0x2aaaab9a4700 (LWP 14473)]
Print 1, thread 1
  C-c C-c

... gdb appears to be hung ...

bash2$ gdb gdb
(top-gdb) attach 14050
Attaching to program: ...
...
0x00002add9e70d5e4 in do_sigsuspend (set=0xbdf380 <suspend_mask>)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:63
63        return INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG /
8);
(top-gdb) bt
#0  0x00002add9e70d5e4 in do_sigsuspend (set=0xbdf380 <suspend_mask>)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:63
#1  __GI___sigsuspend (
During symbol reading, Child DIE 0x116692 and its abstract origin 0x1202c0 have
different tags.
During symbol reading, Child DIE 0x116692 and its abstract origin 0x1202c0 have
different parents.
During symbol reading, Multiple children of DIE 0x118ae5 refer to DIE 0x1156e3
as their abstract origin.
During symbol reading, DW_AT_GNU_call_site_target target DIE has invalid low
pc, for referencing DIE 0x118e57 [in module
/g3/gnu/sourceware/main-gdb-git/b-maste\
r/obj64/gdb/gdb].
set=<optimized out>, set@entry=0xbdf380 <suspend_mask>)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:78
#2  0x00000000004b95ea in wait_lwp (lp=lp@entry=0x227aec0)
    at ../../binutils-gdb/gdb/linux-nat.c:2314
#3  0x00000000004bb315 in stop_wait_callback (lp=0x227aec0,
    data=<optimized out>) at ../../binutils-gdb/gdb/linux-nat.c:2591
#4  0x00000000004ba1c8 in iterate_over_lwps (filter=...,
    callback=callback@entry=0x4bb2c0 <stop_wait_callback>, data=data@entry=0x0)
    at ../../binutils-gdb/gdb/linux-nat.c:1041
#5  0x00000000004bcc21 in linux_nat_wait_1 (ops=<optimized out>,
    target_options=1, ourstatus=0x7fffaeeadeb0, ptid=...)
    at ../../binutils-gdb/gdb/linux-nat.c:3530
#6  linux_nat_wait (ops=<optimized out>, ptid=..., ourstatus=0x7fffaeeadeb0,
    target_options=1) at ../../binutils-gdb/gdb/linux-nat.c:3680
#7  0x00000000004c3364 in thread_db_wait (
During symbol reading, Only single DW_OP_reg or DW_OP_fbreg is supported for
DW_FORM_block* DW_AT_location is supported for DW_TAG_GNU_call_site child DIE
0x74b\
462 [in module /g3/gnu/sourceware/main-gdb-git/b-master/obj64/gdb/gdb].
ops=<optimized out>, ptid=..., ourstatus=0x7fffaeeadeb0, options=1)
    at ../../binutils-gdb/gdb/linux-thread-db.c:1489
#8  0x00000000005e9cae in delegate_wait (self=<optimized out>, arg1=...,
    arg2=<optimized out>, arg3=<optimized out>)
    at ../../binutils-gdb/gdb/target-delegates.c:116
#9  0x00000000005f7425 in target_wait (ptid=..., status=<optimized out>,
    options=<optimized out>) at ../../binutils-gdb/gdb/target.c:2057
#10 0x00000000005b9f4d in fetch_inferior_event (
    client_data=client_data@entry=0x0) at ../../binutils-gdb/gdb/infrun.c:2881
#11 0x00000000005d0453 in inferior_event_handler (event_type=INF_REG_EVENT,
    client_data=0x0) at ../../binutils-gdb/gdb/inf-loop.c:58
#12 0x00000000005ce733 in process_event ()
    at ../../binutils-gdb/gdb/event-loop.c:340
#13 0x00000000005cea4a in gdb_do_one_event ()
    at ../../binutils-gdb/gdb/event-loop.c:392
#14 0x00000000005ceca7 in start_event_loop ()
    at ../../binutils-gdb/gdb/event-loop.c:429
#15 0x00000000005c8283 in captured_command_loop (data=data@entry=0x0)
    at ../../binutils-gdb/gdb/main.c:322
#16 0x00000000005c598a in catch_errors (
    func=func@entry=0x5c8270 <captured_command_loop>,
    func_args=func_args@entry=0x0, errstring=errstring@entry=0x8cb5de "",
    mask=mask@entry=RETURN_MASK_ALL) at ../../binutils-gdb/gdb/exceptions.c:514
#17 0x00000000005c91a6 in captured_main (data=data@entry=0x7fffaeeae1c0)
    at ../../binutils-gdb/gdb/main.c:1178
#18 0x00000000005c598a in catch_errors (
    func=func@entry=0x5c8770 <captured_main>,
    func_args=func_args@entry=0x7fffaeeae1c0,
    errstring=errstring@entry=0x8cb5de "", mask=mask@entry=RETURN_MASK_ALL)
    at ../../binutils-gdb/gdb/exceptions.c:514
#19 0x00000000005c968b in gdb_main (args=args@entry=0x7fffaeeae1c0)
    at ../../binutils-gdb/gdb/main.c:1186
#20 0x00000000004740a5 in main (argc=<optimized out>, argv=<optimized out>)
    at ../../binutils-gdb/gdb/gdb.c:32
(top-gdb) 

... same as 17247.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]