Re: [PATCH v2 28/42] Remove dwarf2_per_cu_data::objfile ()

Tom de Vries
2020-05-27T16:27:29Z

On 12-05-2020 23:12, Simon Marchi via Gdb-patches wrote:
> @@ -724,10 +721,13 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
> caller_frame = get_prev_frame (frame);
>
> parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u,
> - &caller_per_cu);
> + &caller_per_cu,
> + &caller_per_objfile);
> data_src = deref_size == -1 ? parameter->value : parameter->data_value;
> size = deref_size == -1 ? parameter->value_size : parameter->data_value_size;
>
> + gdb_assert (this->per_objfile == caller_per_objfile);
> +

Hi,

I'm running into this assert here:
...
(gdb) PASS: gdb.base/catch-load.exp: plain load: catch load
continue^M
Continuing.^M
^M
Catchpoint 3^M
Inferior loaded
/data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.base/catch-load/catch-load-so.so^M
dl_open_worker (/data/gdb_versions/devel/src/gdb/dwarf2/loc.c:729:
internal-error: virtual void
dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value(call_site_parameter_kind,
call_site_parameter_u, int): Assertion `this->per_objfile ==
caller_per_objfile' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.base/catch-load.exp:
plain load: continue (GDB internal error)
...

Minimal reproducer:
...
$ gdb -batch outputs/gdb.base/catch-load/catch-load \
-ex start \
-ex "catch load" \
-ex continue
...

Actual values at assert:
...
729 gdb_assert (this->per_objfile == caller_per_objfile);
(gdb) p this->per_objfile
$1 = (dwarf2_per_objfile *) 0x1b2f940
(gdb) p caller_per_objfile
$2 = (dwarf2_per_objfile *) 0x1e53da0
(gdb) p *caller_per_objfile
$3 = {objfile = 0x1e53b60, per_bfd = 0x1f0d880, die_type_hash =
std::unique_ptr<htab> = {get() = 0x2054790},
line_header_hash = std::unique_ptr<htab> = {get() = 0x0},
m_symtabs = std::vector of length 1605, capacity 1605 = {0x0,
0x1e3f3a0, 0x0,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 elements, m_dwarf2_cus =
std::unordered_map with 0 elements}
(gdb) p *this->per_objfile
$4 = {objfile = 0x1a6a010, per_bfd = 0x1b4a230, die_type_hash =
std::unique_ptr<htab> = {get() = 0x1c8a570},
line_header_hash = std::unique_ptr<htab> = {get() = 0x0}, m_symtabs =
std::vector of length 83, capacity 83 = {
0x1b3c090, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x200dcb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x210e350, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0}, m_type_units = std::unordered_map with 0 elements,
m_type_map = std::unordered_map with 0 elements, m_dwarf2_cus =
std::unordered_map with 0 elements}
...

Backtrace:
...
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff4f60b01 in __GI_abort () at abort.c:79
#2 0x000000000099247e in dump_core () at
/data/gdb_versions/devel/src/gdb/utils.c:204
#3 0x0000000000992990 in internal_vproblem(internal_problem *, const
char *, int, const char *, typedef __va_list_tag __va_list_tag *)
(problem=0x11ea140 <internal_error_problem>,
file=0xba6060 "/data/gdb_versions/devel/src/gdb/dwarf2/loc.c",
line=729,
fmt=0xba60c8 "%s: Assertion `%s' failed.", ap=0x7fffffffc128) at
/data/gdb_versions/devel/src/gdb/utils.c:414
#4 0x0000000000992a58 in internal_verror (file=0xba6060
"/data/gdb_versions/devel/src/gdb/dwarf2/loc.c",
line=729, fmt=0xba60c8 "%s: Assertion `%s' failed.", ap=0x7fffffffc128)
at /data/gdb_versions/devel/src/gdb/utils.c:439
#5 0x0000000000b083ff in internal_error (file=0xba6060
"/data/gdb_versions/devel/src/gdb/dwarf2/loc.c",
line=729, fmt=0xba60c8 "%s: Assertion `%s' failed.") at
/data/gdb_versions/devel/src/gdbsupport/errors.cc:55
#6 0x00000000005bfb30 in
dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value (this=0x7fffffffc550,
kind=CALL_SITE_PARAMETER_DWARF_REG, kind_u=..., deref_size=-1)
at /data/gdb_versions/devel/src/gdb/dwarf2/loc.c:729
#7 0x000000000058aa15 in dwarf_expr_context::execute_stack_op
(this=0x7fffffffc550,
op_ptr=0x7ffff00425b3 "\237\245\016", op_end=0x7ffff00425b4 "\245\016")
at /data/gdb_versions/devel/src/gdb/dwarf2/expr.c:1292
#8 0x00000000005886b6 in dwarf_expr_context::eval (this=0x7fffffffc550,
addr=0x7ffff00425b0 "\363\001U\237\245\016", len=4) at
/data/gdb_versions/devel/src/gdb/dwarf2/expr.c:303
#9 0x00000000005ba36c in dwarf2_evaluate_loc_desc_full (type=0x1c890c0,
frame=0x2006570,
data=0x7ffff00425b0 "\363\001U\237\245\016", size=4,
per_cu=0x1b80fb0, per_objfile=0x1b2f940,
subobj_type=0x1c890c0, subobj_byte_offset=0) at
/data/gdb_versions/devel/src/gdb/dwarf2/loc.c:2230
#10 0x00000000005baa55 in dwarf2_evaluate_loc_desc (type=0x1c890c0,
frame=0x2006570,
data=0x7ffff00425b0 "\363\001U\237\245\016", size=4,
per_cu=0x1b80fb0, per_objfile=0x1b2f940)
--Type <RET> for more, q to quit, c to continue without paging--
at /data/gdb_versions/devel/src/gdb/dwarf2/loc.c:2414
#11 0x00000000005befe4 in loclist_read_variable (symbol=0x20f7460,
frame=0x2006570)
at /data/gdb_versions/devel/src/gdb/dwarf2/loc.c:4474
#12 0x000000000065001b in default_read_var_value (var=0x20f7460,
var_block=0x0, frame=0x2006570)
at /data/gdb_versions/devel/src/gdb/findvar.c:610
#13 0x0000000000650b57 in read_var_value (var=0x20f7460, var_block=0x0,
frame=0x2006570)
at /data/gdb_versions/devel/src/gdb/findvar.c:815
#14 0x00000000008a7051 in read_frame_arg (fp_opts=..., sym=0x20f7460,
frame=0x2006570, argp=0x7fffffffc970,
entryargp=0x7fffffffc990) at
/data/gdb_versions/devel/src/gdb/stack.c:542
#15 0x00000000008a7c28 in print_frame_args (fp_opts=..., func=0x20f73e0,
frame=0x2006570, num=-1,
stream=0x1ab1f20) at /data/gdb_versions/devel/src/gdb/stack.c:884
#16 0x00000000008a8e3d in print_frame (fp_opts=..., frame=0x2006570,
print_level=0, print_what=SRC_AND_LOC,
print_args=1, sal=...) at /data/gdb_versions/devel/src/gdb/stack.c:1388
#17 0x00000000008a84f5 in print_frame_info (fp_opts=...,
frame=0x2006570, print_level=0, print_what=SRC_AND_LOC,
print_args=1, set_current_sal=1) at
/data/gdb_versions/devel/src/gdb/stack.c:1113
#18 0x00000000008a6882 in print_stack_frame (frame=0x2006570,
print_level=0, print_what=SRC_AND_LOC,
set_current_sal=1) at /data/gdb_versions/devel/src/gdb/stack.c:366
#19 0x00000000006eed37 in print_stop_location (ws=0x7fffffffcec0)
at /data/gdb_versions/devel/src/gdb/infrun.c:8352
#20 0x00000000006eed95 in print_stop_event (uiout=0x1ab3380, displays=true)
at /data/gdb_versions/devel/src/gdb/infrun.c:8368
#21 0x0000000000948783 in tui_on_normal_stop (bs=0x2054b90, print_frame=1)
at /data/gdb_versions/devel/src/gdb/tui/tui-interp.c:98
#22 0x0000000000448abf in std::_Function_handler<void (bpstats*, int),
void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&,
int&&) (__functor=..., __args#0=@0x7fffffffcfd0: 0x2054b90,
--Type <RET> for more, q to quit, c to continue without paging--
__args#1=@0x7fffffffcfcc: 1) at
/usr/include/c++/7/bits/std_function.h:316
#23 0x00000000006f3ce2 in std::function<void (bpstats*,
int)>::operator()(bpstats*, int) const (this=0x133ae70,
__args#0=0x2054b90, __args#1=1) at
/usr/include/c++/7/bits/std_function.h:706
#24 0x00000000006f2ffc in gdb::observers::observable<bpstats*,
int>::notify (
this=0x1211260 <gdb::observers::normal_stop>, args#0=0x2054b90,
args#1=1)
at /data/gdb_versions/devel/src/gdb/../gdbsupport/observable.h:106
#25 0x00000000006ef530 in normal_stop () at
/data/gdb_versions/devel/src/gdb/infrun.c:8646
#26 0x00000000006e53e9 in fetch_inferior_event (client_data=0x0)
at /data/gdb_versions/devel/src/gdb/infrun.c:4065
#27 0x00000000006caa9d in inferior_event_handler
(event_type=INF_REG_EVENT, client_data=0x0)
at /data/gdb_versions/devel/src/gdb/inf-loop.c:43
#28 0x0000000000724581 in handle_target_event (error=0, client_data=0x0)
at /data/gdb_versions/devel/src/gdb/linux-nat.c:4235
#29 0x0000000000b09018 in handle_file_event (file_ptr=0x1afb810,
ready_mask=1)
at /data/gdb_versions/devel/src/gdbsupport/event-loop.cc:548
#30 0x0000000000b095a0 in gdb_wait_for_event (block=0)
at /data/gdb_versions/devel/src/gdbsupport/event-loop.cc:673
#31 0x0000000000b08533 in gdb_do_one_event () at
/data/gdb_versions/devel/src/gdbsupport/event-loop.cc:190
#32 0x0000000000920c72 in wait_sync_command_done () at
/data/gdb_versions/devel/src/gdb/top.c:526
#33 0x0000000000920cea in maybe_wait_sync_command_done (was_sync=0) at
/data/gdb_versions/devel/src/gdb/top.c:543
#34 0x0000000000921179 in execute_command (p=0x7fffffffe117 "", from_tty=0)
at /data/gdb_versions/devel/src/gdb/top.c:657
#35 0x000000000074a197 in catch_command_errors (command=0x920d03
<execute_command(char const*, int)>,
arg=0x7fffffffe10f "continue", from_tty=0) at
/data/gdb_versions/devel/src/gdb/main.c:457
#36 0x000000000074b57f in captured_main_1 (context=0x7fffffffda00)
--Type <RET> for more, q to quit, c to continue without paging--
at /data/gdb_versions/devel/src/gdb/main.c:1219
#37 0x000000000074b774 in captured_main (data=0x7fffffffda00) at
/data/gdb_versions/devel/src/gdb/main.c:1244
#38 0x000000000074b7df in gdb_main (args=0x7fffffffda00) at
/data/gdb_versions/devel/src/gdb/main.c:1269
#39 0x000000000041515e in main (argc=14, argv=0x7fffffffdb08) at
/data/gdb_versions/devel/src/gdb/gdb.c:32
...

Thanks,
- Tom