Refrain from asking debug stubs to read invalid memory
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
Some stubs take exception to this.
For example we observe RTEMS's libdebugger freezing when asked to examine
address zero on aarch64/xilinx_zynqmp_lp64_qemu. As of 2024-02-02 "gdb,
types: Resolve pointer types dynamically" (f18fc7e56fb) this happens as
early as 'target remote'. Ordinarily we would be greeted with…
_User_extensions_Thread_switch (executing=0x0, heir=<optimized out>)
at […]/cpukit/include/rtems/score/userextimpl.h:382
… but now, as language_defn::read_var_value calls resolve_dynamic_type with
a "dummy" address and value, resolve_dynamic_type_internal receives a
similarly "dummy" addr_stack, and attempts to read memory address zero:
guard against that.
---
gdb/gdbtypes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -2805,7 +2805,7 @@ resolve_dynamic_type_internal (struct type *type,
if (addr_stack->valaddr.data () != NULL)
pinfo.addr = extract_typed_address (addr_stack->valaddr.data (),
type);
- else
+ else if (addr_stack->addr != 0)
pinfo.addr = read_memory_typed_address (addr_stack->addr, type);
pinfo.next = addr_stack;