https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70548
Henrique Andrade <hcma at unscrambl dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hcma at unscrambl dot com
--- Comment #1 from Henrique Andrade <hcma at unscrambl dot com> ---
I also have a reproducible example where this happens, using GNU gdb (GDB) Red
Hat Enterprise Linux 7.6.1-80.el7.
In my case it happens when a process starts a child process with gdb being
exec'ed as follows:
gdb -n -ex thread apply all bt full -batch -pid <pid>
When inspecting gdb's stack trace I see:
(gdb) where
#0 0x00007ff8e6135a73 in __pread_nocancel () at
../sysdeps/unix/syscall-template.S:81
#1 0x00000000004cdb0f in linux_xfer_partial ()
#2 0x00000000004cea9e in linux_nat_xfer_partial ()
#3 0x00000000005fc1dc in memory_xfer_partial_1 ()
#4 0x00000000005fc78d in target_xfer_partial ()
#5 0x00000000005fbdc9 in target_read ()
#6 0x00000000005fbe50 in target_read_memory ()
#7 0x00000000005973b2 in partial_memory_read ()
#8 0x000000000059a1a9 in read_string ()
#9 0x000000000059b64f in val_print_string ()
#10 0x00000000005308d6 in apply_val_pretty_printer ()
#11 0x00000000005981f5 in val_print ()
#12 0x00000000005982c7 in common_val_print ()
#13 0x0000000000530ab5 in apply_val_pretty_printer ()
#14 0x00000000005981f5 in val_print ()
#15 0x00000000005982c7 in common_val_print ()
#16 0x000000000059feda in print_variable_and_value ()
#17 0x00000000005cc7c3 in do_print_variable_and_value ()
#18 0x00000000005ce444 in iterate_over_block_local_vars ()
#19 0x00000000005ce58c in print_frame_local_vars ()
#20 0x00000000005ce7c0 in backtrace_command_1 ()
#21 0x00000000005cec25 in backtrace_command ()
#22 0x0000000000695b0a in execute_command ()
#23 0x00000000005d398c in thread_apply_all_command ()
And strace shows it spinning as such:
ptrace(PTRACE_PEEKTEXT, 6820, 0x7f5a86d1f348, [0]) = 0
open("/proc/6820/mem", O_RDONLY) = 20
pread(20,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
33738576, 140026785690448) = 16596144
close(20) = 0
ptrace(PTRACE_PEEKTEXT, 6820, 0x7f5a86d1f350, [0]) = 0
open("/proc/6820/mem", O_RDONLY) = 20
pread(20,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
33738568, 140026785690456) = 16596136
close(20) = 0
ptrace(PTRACE_PEEKTEXT, 6820, 0x7f5a86d1f358, [0]) = 0
open("/proc/6820/mem", O_RDONLY) = 20
pread(20,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
33738560, 140026785690464) = 16596128
close(20)
... (ad infinitum)
If I replace the invocation line to:
gdb -n -ex "disable pretty-printer" -ex "thread apply all bt fullä -batch -pid
<pid>
The problem goes away and the gdb subprocess prints out the stack trace and
terminates as expected.