[Bug gdb/34047] gdb Fatal signal: Bus error | SIGBUS (Misaligned address error)

simark at simark dot ca via Gdb-prs <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34047

--- Comment #13 from Simon Marchi <simark at simark dot ca> ---
Ok, I built my own gdb inside the container and got a nice backtrace (see
below).  I am not sure we're looking at the same thing as your original report
though.

The problem looks like:

 - inf 1 vforks, creating inf 2, and we want to detach from inf 1
 - handle_vfork_child_exec_or_exit purposefully sets inf 2's pspace to nullptr
while detaching inf 1, as explained here:

  
https://gitlab.com/gnutools/binutils-gdb/-/blob/cd05beed352d69e282e9fae6f69bfec48a8faedf/gdb/infrun.c#L1118
 - while detaching, the inferior_disappeared observer gets called, which sends
the Python "inferior exited" event
 - the Python code calls "info program"
 - the handler for "info program" obtains a thread using get_previous_thread(),
which returns a thread from inf 2
 - it tries to switch to that thread, which tries to set that inferior's pspace
as the current program space, and because it is nullptr the assert triggers



#8  0x000055f94ff03d87 in internal_error_loc (file=0x55f95000acbf
"/binutils-gdb/gdb/progspace.c", line=248, fmt=0x55f95000ac28 "%s: Assertion
`%s' failed.") at /binutils-gdb/gdbsupport/errors.cc:57
#9  0x000055f94fa02271 in set_current_program_space (pspace=0x0) at
/binutils-gdb/gdb/progspace.c:248
#10 0x000055f94fc4256b in switch_to_thread_no_regs (thread=0x55f951a50350) at
/binutils-gdb/gdb/thread.c:1464
#11 0x000055f94fc426ee in switch_to_thread (thr=0x55f951a50350) at
/binutils-gdb/gdb/thread.c:1496
#12 0x000055f94f895b66 in info_program_command (args=0x0, from_tty=0) at
/binutils-gdb/gdb/infcmd.c:2102
#13 0x000055f94f5b7dbf in do_simple_func (args=0x0, from_tty=0,
c=0x55f9509b1090) at /binutils-gdb/gdb/cli/cli-decode.c:86
#14 0x000055f94f5be3dd in cmd_func (cmd=0x55f9509b1090, args=0x0, from_tty=0)
at /binutils-gdb/gdb/cli/cli-decode.c:2810
#15 0x000055f94fc4cf64 in execute_command (p=0x7ffdeeade96c "", from_tty=0) at
/binutils-gdb/gdb/top.c:632
#16 0x000055f94f5ce2ea in execute_control_command_1 (cmd=0x55f95150e650,
from_tty=0) at /binutils-gdb/gdb/cli/cli-script.c:530
#17 0x000055f94f5cea1e in execute_control_command (cmd=0x55f95150e650,
from_tty=0) at /binutils-gdb/gdb/cli/cli-script.c:706
#18 0x000055f94f5cdd5d in execute_control_commands (cmdlines=0x55f95150e650,
from_tty=0) at /binutils-gdb/gdb/cli/cli-script.c:412
#19 0x000055f94f5cde42 in operator() (__closure=0x7ffdeeadec40) at
/binutils-gdb/gdb/cli/cli-script.c:433
#20 0x000055f94f5d232c in std::__invoke_impl<void,
execute_control_commands_to_string(command_line*, int,
bool)::<lambda()>&>(std::__invoke_other, struct {...} &) (__f=...) at
/usr/include/c++/13/bits/invoke.h:61
#21 0x000055f94f5d2213 in std::__invoke_r<void,
execute_control_commands_to_string(command_line*, int,
bool)::<lambda()>&>(struct {...} &) (__fn=...) at
/usr/include/c++/13/bits/invoke.h:111
#22 0x000055f94f5d20d3 in std::_Function_handler<void(),
execute_control_commands_to_string(command_line*, int, bool)::<lambda()>
>::_M_invoke(const std::_Any_data &) (__functor=...) at
/usr/include/c++/13/bits/std_function.h:290
#23 0x000055f94f5daa30 in std::function<void()>::operator()
(this=0x7ffdeeadec40) at /usr/include/c++/13/bits/std_function.h:591
#24 0x000055f94fc4d3ba in execute_fn_to_ui_file (file=0x7ffdeeadec60, fn=...)
at /binutils-gdb/gdb/top.c:684
#25 0x000055f94fc4d5fa in execute_fn_to_string (res="", fn=..., term_out=true)
at /binutils-gdb/gdb/top.c:697
#26 0x000055f94f5cdeb9 in
execute_control_commands_to_string[abi:cxx11](command_line*, int, bool)
(commands=0x55f95150e650, from_tty=0, term_out=true) at
/binutils-gdb/gdb/cli/cli-script.c:431
#27 0x000055f94faa2d2c in execute_gdb_command (self=0x7f5e95de1d00,
args=0x7f5e8c2f2860, kw=0x7f5e8c31a700) at
/binutils-gdb/gdb/python/python.c:780
#28 0x00007f5ea24454b8 in cfunction_call (func=0x7f5e95e00a90,
args=0x7f5e8c2f2860, kwargs=0x7f5e8c31a700) at ../Objects/methodobject.c:537
#29 0x00007f5ea23e87df in _PyObject_MakeTpCall (tstate=0x7f5ea2b09668
<_PyRuntime+459656>, callable=callable@entry=0x7f5e95e00a90,
args=args@entry=0x7f5e95ed73c8, nargs=<optimized out>, keywords=0x7f5e94f43b80)
at ../Objects/call.c:240
#30 0x00007f5ea23e8b77 in _PyObject_VectorcallTstate (kwnames=<optimized out>,
nargsf=<optimized out>, args=0x7f5e95ed73c8, callable=0x7f5e95e00a90,
tstate=<optimized out>) at ../Include/internal/pycore_call.h:90
#31 0x00007f5ea23835ee in _PyEval_EvalFrameDefault (tstate=<optimized out>,
frame=<optimized out>, throwflag=<optimized out>) at Python/bytecodes.c:2706
#32 0x00007f5ea267d2bd in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=2,
args=0x7ffdeeadf120, callable=0x7f5e94c83920, tstate=0x7f5ea2b09668
<_PyRuntime+459656>) at ../Include/internal/pycore_call.h:92
#33 partial_vectorcall (pto=0x7f5e943c9da0, args=<optimized out>,
nargsf=<optimized out>, kwnames=0x0) at ../Modules/_functoolsmodule.c:267
#34 0x00007f5ea237fdec in _PyEval_EvalFrameDefault (tstate=<optimized out>,
frame=<optimized out>, throwflag=<optimized out>) at Python/bytecodes.c:3254
#35 0x00007f5ea23e8d9e in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=1,
args=0x7ffdeeadf350, callable=0x7f5e943ec9a0, tstate=0x7f5ea2b09668
<_PyRuntime+459656>) at ../Include/internal/pycore_call.h:92
#36 object_vacall (tstate=0x7f5ea2b09668 <_PyRuntime+459656>,
base=base@entry=0x0, callable=callable@entry=0x7f5e943ec9a0,
vargs=vargs@entry=0x7ffdeeadf3c8) at ../Objects/call.c:850
#37 0x00007f5ea23e92de in PyObject_CallFunctionObjArgs
(callable=0x7f5e943ec9a0) at ../Objects/call.c:957
#38 0x000055f94fa2d93e in evpy_emit_event (event=0x7f5e8c2536b0,
registry=0x7f5e95b8ec30) at /binutils-gdb/gdb/python/py-event.c:86
#39 0x000055f94fa2ec2a in emit_exited_event (exit_code=0x0, inf=0x55f9509694e0)
at /binutils-gdb/gdb/python/py-exitedevent.c:62
#40 0x000055f94fa3bbe5 in python_inferior_exit (inf=0x55f9509694e0) at
/binutils-gdb/gdb/python/py-inferior.c:162
#41 0x000055f94f4603a8 in std::__invoke_impl<void, void (*&)(inferior*),
inferior*> (__f=@0x55f950a76810: 0x55f94fa3bb55
<python_inferior_exit(inferior*)>) at /usr/include/c++/13/bits/invoke.h:61
#42 0x000055f94f45b10b in std::__invoke_r<void, void (*&)(inferior*),
inferior*> (__fn=@0x55f950a76810: 0x55f94fa3bb55
<python_inferior_exit(inferior*)>) at /usr/include/c++/13/bits/invoke.h:111
#43 0x000055f94f4566f0 in std::_Function_handler<void(inferior*), void
(*)(inferior*)>::_M_invoke (__functor=..., __args#0=@0x7ffdeeadf660:
0x55f9509694e0) at /usr/include/c++/13/bits/std_function.h:290
#44 0x000055f94f630311 in std::function<void(inferior*)>::operator()
(this=0x55f950a76810, __args#0=0x55f9509694e0) at
/usr/include/c++/13/bits/std_function.h:591
#45 0x000055f94f62d55e in gdb::observers::observable<inferior*>::notify
(this=0x55f9504f55e0 <gdb::observers::inferior_exit>, args#0=0x55f9509694e0) at
/binutils-gdb/gdb/../gdbsupport/observable.h:166
#46 0x000055f94f89d927 in notify_inferior_disappeared (inf=0x55f9509694e0) at
/binutils-gdb/gdb/inferior.c:305
#47 0x000055f94f89d961 in exit_inferior (inf=0x55f9509694e0) at
/binutils-gdb/gdb/inferior.c:315
#48 0x000055f94fc1b075 in generic_mourn_inferior () at
/binutils-gdb/gdb/target.c:3666
#49 0x000055f94fb0537f in remote_target::mourn_inferior (this=0x55f95187bde0)
at /binutils-gdb/gdb/remote.c:11228
#50 0x000055f94fc190aa in target_mourn_inferior (ptid=...) at
/binutils-gdb/gdb/target.c:2771
#51 0x000055f94faf842b in remote_target::remote_detach_1 (this=0x55f95187bde0,
inf=0x55f9509694e0, from_tty=0) at /binutils-gdb/gdb/remote.c:6957
#52 0x000055f94faf8513 in remote_target::detach (this=0x55f95187bde0,
inf=0x55f9509694e0, from_tty=0) at /binutils-gdb/gdb/remote.c:6972
#53 0x000055f94fc1830f in target_detach (inf=0x55f9509694e0, from_tty=0) at
/binutils-gdb/gdb/target.c:2568
#54 0x000055f94f8a9e57 in handle_vfork_child_exec_or_exit (exec=1) at
/binutils-gdb/gdb/infrun.c:1140
#55 0x000055f94f8b96d5 in handle_inferior_event (ecs=0x7ffdeeadff30) at
/binutils-gdb/gdb/infrun.c:6630
#56 0x000055f94f8b414d in fetch_inferior_event () at
/binutils-gdb/gdb/infrun.c:4756
#57 0x000055f94f885a69 in inferior_event_handler (event_type=INF_REG_EVENT) at
/binutils-gdb/gdb/inf-loop.c:42
#58 0x000055f94fb14070 in remote_async_serial_handler (scb=0x55f951882470,
context=0x55f95187c148) at /binutils-gdb/gdb/remote.c:15975
#59 0x000055f94fb49f7e in run_async_handler_and_reschedule (scb=0x55f951882470)
at /binutils-gdb/gdb/ser-base.c:138
#60 0x000055f94fb4a065 in fd_event (error=0, context=0x55f951882470) at
/binutils-gdb/gdb/ser-base.c:189
#61 0x000055f94ff04e93 in handle_file_event (file_ptr=0x55f951b0d520,
ready_mask=1) at /binutils-gdb/gdbsupport/event-loop.cc:551
#62 0x000055f94ff05514 in gdb_wait_for_event (block=1) at
/binutils-gdb/gdbsupport/event-loop.cc:672
#63 0x000055f94ff042d2 in gdb_do_one_event (mstimeout=-1) at
/binutils-gdb/gdbsupport/event-loop.cc:263
#64 0x000055f94f5c5e73 in interp::do_one_event (this=0x55f950b6f170,
mstimeout=-1) at /binutils-gdb/gdb/interps.h:90
#65 0x000055f94f95a784 in start_event_loop () at /binutils-gdb/gdb/main.c:400
#66 0x000055f94f95a974 in captured_command_loop () at
/binutils-gdb/gdb/main.c:465
#67 0x000055f94f95c656 in captured_main (context=0x7ffdeeae0380) at
/binutils-gdb/gdb/main.c:1373
#68 0x000055f94f95c700 in gdb_main (args=0x7ffdeeae0380) at
/binutils-gdb/gdb/main.c:1392
#69 0x000055f94f3eb39f in main (argc=5, argv=0x7ffdeeae04c8) at
/binutils-gdb/gdb/gdb.c:38

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.