public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/27315] New: Walking threads during frame display pretty-printer causes crashes
@ 2021-02-02 13:40 psmith at gnu dot org
  2021-02-02 13:40 ` [Bug python/27315] " psmith at gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: psmith at gnu dot org @ 2021-02-02 13:40 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 27315
           Summary: Walking threads during frame display pretty-printer
                    causes crashes
           Product: gdb
           Version: 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: psmith at gnu dot org
  Target Milestone: ---

Created attachment 13194
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13194&action=edit
Repro source file

I can consistently make GDB either loop continuously during backtrace, or crash
showing a frame, by adding a pretty-printer that queries the GDB threads()
method on the inferior.

Compile the attached foo.cpp file; MUST be compiled with -pthreads!

$ g++ -g -ggdb3 -pthread -o foo foo.cpp

Now run it to get a core:

$ ./foo hiya
hiya
Aborted (core dumped)

Now you can see the backtrace if you use GDB and it works fine:

$ gdb -q -batch -ex 'bt' -c core foo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./foo hiya'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f28af56a18b in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0  0x00007f28af56a18b in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f28af549859 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000055e3b4dc4203 in foo (f=...) at foo.cpp:13
#3  0x000055e3b4dc4256 in main (argc=2, argv=0x7ffe1045c1c8) at foo.cpp:20

Now try the same thing using the attached pretty-printer:

$ gdb -q -x foo.py -batch -ex 'bt' -c core foo

On my system this will recursively try to print the backtrace over and over for
a while, after which it will either "succeed", or GDB will dump core with:

gdb/frame.c:2467: internal-error: bool get_frame_pc_if_available(frame_info*,
CORE_ADDR*): Assertion `frame->next != NULL' failed.

If you change the pretty-printer implementation from:

        gdb.selected_inferior().threads()

to just:

        gdb.selected_inferior()

it works fine again.

Also if I edited gdb/ptyhon/py-inferior.c and removed the update_thread_list()
call changing:

   try
     {
       update_thread_list ();
     }
   catch (const gdb_exception &except)
     {

to:

   try
     {
       // update_thread_list ();
     }
   catch (const gdb_exception &except)
     {

it also works fine.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-01 18:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 13:40 [Bug python/27315] New: Walking threads during frame display pretty-printer causes crashes psmith at gnu dot org
2021-02-02 13:40 ` [Bug python/27315] " psmith at gnu dot org
2021-02-02 14:29 ` simark at simark dot ca
2021-02-02 14:37 ` simark at simark dot ca
2022-02-21  1:34 ` psmith at gnu dot org
2023-08-01 18:18 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).