Bug 28389 - Assertion depth > 0 failed in inline_frame_sniffer
Summary: Assertion depth > 0 failed in inline_frame_sniffer
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: backtrace (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-27 12:40 UTC by Nuno Paulino
Modified: 2024-03-25 16:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
ELF File and setup required to compile (if necessary) (1.31 MB, application/zip)
2021-09-27 12:40 UTC, Nuno Paulino
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Paulino 2021-09-27 12:40:57 UTC
Created attachment 13680 [details]
ELF File and setup required to compile (if necessary)

Assertion in inline_frame_sniffer (line 245) fails when encountering any inlined function for target microblaze-xilinx-elf.

I am using a GDB + QEMU setup to execute my target ELF files. 
GDB version: GNU gdb (GDB) 10.0.50.20200730-git
(built from either Xilinx's fork, the mirror at bminor - https://github.com/bminor/binutils-gdb/releases - or even the latest commit in sourceware, i.e., a few hours ago at the time of this bug report, 27 sep 2021)

QEMU: QEMU emulator version 5.1.0 (v2.6.0-35778-ge40b634b24-dirty)
(note that this is the Xilinx branch of QEMU, since a specific target machine `microblaze-fdt-plnx' is required; DTB included in attachment; repo for this fork is at https://github.com/Xilinx/qemu)

Attached are the source, makefile, and compiled ELF.

Steps to reproduce:

1. Launch QEMU with `qemu-system-microblazeel -nographic -M microblaze-fdt-plnx -m 128 -display none -kernel dotprod.elf -dtb system.dtb -gdb tcp::1234 -S`
2. Launch mb-gdb
2.1 file dotprod.elf
2.2 target remote localhost:1234
2.3 break frame_dummy
   (this is only the first case in which the issue occurs, and its in initialization code common to all ELFs)
2.4 c
2.5 (when break hits, then stepi), until this assertion:

Breakpoint 1, 0x000001f0 in frame_dummy ()
(gdb) stepi
0x000001f4 in frame_dummy ()
(gdb) 
0x00000214 in frame_dummy ()
(gdb) 
0x00000218 in frame_dummy ()
(gdb) 
inline-frame.c:244: internal-error: int inline_frame_sniffer(const frame_unwind*, frame_info*, void**): Assertion `depth > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n

Continuing is impossible.

Note that I can set a breakpoint at "main" (or any other user function) and continue to that point. By then issuing "stepi", this assertion fails on any function that the compiler has inlined, OR any function declared as static (due to implicing inlining I presume). I've verified that by removing all "static" qualifiers, and using the " -fno-inline-functions -fno-inline-small-functions" flags, I can step through all user code normally. However, once the _exit routines are reached, the assertion fails again, since this library/init code has been compiled with inlined functions (assumption?).
Comment 1 Sean Anderson 2024-03-25 16:11:55 UTC
I reproduced this on origin/master:

GNU gdb (GDB) 15.0.50.20240325-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=microblaze".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...

warning: ~/.gdbinit.local: No such file or directory
Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled on'.

Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

Reading symbols from build/tmp2/deploy/images/anya2/pmu-firmware-anya2.elf...
gdb$ hb XPfw_CoreDispatchIpiQuit
gdb$ tar ext :3002
Remote debugging using :3002
inline-frame.c:244: internal-error: inline_frame_sniffer: Assertion `depth > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x55bc4af17511 gdb_internal_backtrace_1
	gdb/bt-utils.c:122
0x55bc4af17511 _Z22gdb_internal_backtracev
	gdb/bt-utils.c:168
0x55bc4b2f09ec internal_vproblem
	gdb/utils.c:421
0x55bc4b2f0ca0 _Z15internal_verrorPKciS0_P13__va_list_tag
	gdb/utils.c:501
0x55bc4b428264 _Z18internal_error_locPKciS0_z
	gdbsupport/errors.cc:58
0x55bc4b0d01f7 inline_frame_sniffer
	gdb/inline-frame.c:244
0x55bc4b0492ca frame_unwind_try_unwinder
	gdb/frame-unwind.c:138
0x55bc4b049f26 _Z26frame_unwind_find_by_frameRK14frame_info_ptrPPv
	gdb/frame-unwind.c:209
0x55bc4b04d34b compute_frame_id
	gdb/frame.c:605
0x55bc4b05200d get_prev_frame_maybe_check_cycle
	gdb/frame.c:2214
0x55bc4b052466 get_prev_frame_always_1
	gdb/frame.c:2327
0x55bc4b052abf _Z21get_prev_frame_alwaysRK14frame_info_ptr
	gdb/frame.c:2476
0x55bc4b0cfa27 inline_frame_this_id
	gdb/inline-frame.c:166
0x55bc4b04d248 compute_frame_id
	gdb/frame.c:610
0x55bc4b051d95 _Z12get_frame_idRK14frame_info_ptr
	gdb/frame.c:653
0x55bc4b051d95 _Z12get_frame_idRK14frame_info_ptr
	gdb/frame.c:634
0x55bc4b30a157 _Z12value_assignP5valueS0_
	gdb/valops.c:1116
0x55bc4b023d12 _ZN10expression8evaluateEP4type6noside
	gdb/eval.c:111
0x55bc4b14d50f set_command
	gdb/printcmd.c:1477
0x55bc4af47104 _Z8cmd_funcP16cmd_list_elementPKci
	cli/cli-decode.c:2742
0x55bc4b28f948 _Z15execute_commandPKci
	gdb/top.c:571
0x55bc4af529fa execute_control_command_1
	cli/cli-script.c:529
0x55bc4af52bc8 execute_control_command_1
	cli/cli-script.c:641
0x55bc4af52e31 _Z24execute_control_commandsP12command_linei
	cli/cli-script.c:411
0x55bc4af52f64 _Z20execute_user_commandP16cmd_list_elementPKc
	cli/cli-script.c:461
0x55bc4af5311c _Z20execute_cmd_pre_hookP16cmd_list_element
	cli/cli-script.c:385
0x55bc4b0b5410 _Z11normal_stopv
	gdb/infrun.c:9590
0x55bc4b0c7545 _Z12start_remotei
	gdb/infrun.c:3812
0x55bc4b1e5595 _ZN13remote_target14start_remote_1Eii
	gdb/remote.c:5271
0x55bc4b1e5d0b _ZN13remote_target12start_remoteEii
	gdb/remote.c:5362
0x55bc4b1e5d0b _ZN13remote_target6open_1EPKcii
	gdb/remote.c:6223
0x55bc4b27fab3 open_target
	gdb/target.c:824
0x55bc4af47104 _Z8cmd_funcP16cmd_list_elementPKci
	cli/cli-decode.c:2742
0x55bc4b28f948 _Z15execute_commandPKci
	gdb/top.c:571
0x55bc4b02add7 _Z15command_handlerPKc
	gdb/event-top.c:567
0x55bc4b02bf93 _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
	gdb/event-top.c:803
0x55bc4b02b79b gdb_rl_callback_handler
	gdb/event-top.c:259
0x55bc4b368f27 rl_callback_read_char
	readline/readline/callback.c:290
0x55bc4b369183 rl_callback_read_char
	readline/readline/callback.c:224
0x55bc4b02a90d gdb_rl_callback_read_char_wrapper_noexcept
	gdb/event-top.c:195
0x55bc4b02b654 gdb_rl_callback_read_char_wrapper
	gdb/event-top.c:234
0x55bc4b2c76ff stdin_event_handler
	gdb/ui.c:155
0x55bc4b428ed5 gdb_wait_for_event
	gdbsupport/event-loop.cc:694
0x55bc4b4296bf gdb_wait_for_event
	gdbsupport/event-loop.cc:593
0x55bc4b4296bf _Z16gdb_do_one_eventi
	gdbsupport/event-loop.cc:264
0x55bc4b0f8999 start_event_loop
	gdb/main.c:401
0x55bc4b0f8999 captured_command_loop
	gdb/main.c:465
0x55bc4b0fa9a4 captured_main
	gdb/main.c:1339
0x55bc4b0fa9a4 _Z8gdb_mainP18captured_main_args
	gdb/main.c:1358
0x55bc4ae692eb main
	gdb/gdb.c:39
---------------------

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

Aborted (core dumped)