From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2AB333858C53; Thu, 29 Feb 2024 17:55:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AB333858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709229316; bh=bKs4tky1k+r9127EK50sT4SApP/sM60ZQT1VLHef38g=; h=From:To:Subject:Date:From; b=qmcj8R5IwZ7/VwSvg//o8JlhLTbFe1hvH5J1NVDSjaRyDrHTaNz/hKrChu5p/oSUx skHLENot9jqm1zxI7SV+rS2ZSNEhvibk/DAWXvDc95zAeWHSU2Yb2XBMQbidT+YvyY WRwne21xciNKJNaRlM7/tPxMzkk6l40l8c8wsp8o= From: "lukas.graetz@tu-darmstadt.de" To: gdb-prs@sourceware.org Subject: [Bug gdb/31436] New: with .cfi_undefined Date: Thu, 29 Feb 2024 17:55:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 15.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lukas.graetz@tu-darmstadt.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31436 Bug ID: 31436 Summary: with .cfi_undefined Product: gdb Version: 15.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: lukas.graetz@tu-darmstadt.de Target Milestone: --- Created attachment 15384 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15384&action=3Ded= it bar-artificial.zip Backstory: Currently, the gcc trunk (14.0.1 20240228 (experimental)) has an optimizati= on to not save callee-saved registers for noreturn functions [1]. It was obser= ved in [2] that gdb printed out incorrect variable values due to clobbered registers. A fix adds ".cfi_undefined" annotations [3]. --- The problem for gdb: The backtrace is still incorrect (also observed in [2]): $ gdb bar-artificial-fix-undefined GNU gdb (GDB) 15.0.50.20240229-git (gdb) run Starting program: bar-artificial-fix-undefined Program received signal SIGABRT, Aborted. 0x00007ffff7dee00b in raise () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff7dee00b in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff7dcd859 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00000000004011b0 in bar () at bar-artificial.c:30 #3 0x00000000004011d1 in baz ( a=3D,=20 b=3D, c=3D, d=3D,=20 e=3D, f=3D, g=3D48, h=3D49) at bar-artifi= cial.c:38 Here, the backtrace did not reach the functions qux() and main(). In this c= ase, the stack base pointer rbp was clobbered and marked with .cfi_undefined. Bu= t it still should be possible without rbp to reconstruct the backtrace. --- There is also another patch [4] to partially revert [1] by saving rbp only. When applying this patch (and manually adding .cfi_undefined to the assembl= er output, because both patches [3],[4] are incompatible), we get the following result: $ gdb bar-artificial-save-rbp (gdb) run Program received signal SIGABRT, Aborted. (gdb) bt #0 0x00007ffff7dee00b in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff7dcd859 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00000000004011b1 in bar () at bar-artificial.c:30 #3 0x00000000004011d2 in baz (a=3Da@entry=3D42, b=3Db@entry=3D43, c=3Dc@en= try=3D44,=20 d=3D,=20 e=3D,=20 f=3D, g=3D48, h= =3D49) at bar-artificial.c:38 #4 0x00000000004012aa in qux () at bar-artificial.c:55 #5 0x00000000004012e4 in main () at bar-artificial.c:62 Were it just it would be as expected, but the wording "error reading" still leaves the question whether there went something wrong. --- How to reproduce: See the attached .zip archive. To run it yourself, you don't need to build = the gcc trunk, you can just use the .S files on x86-64. $ gcc bar-artificial-fix-undefined.S -o bar-artificial-fix-undefined $ gcc bar-artificial-save-rbp.S -o bar-artificial-save-rbp [[ Was produced by $ cc1 -Og -g bar-artificial.c -o bar-artificial-fix-undefined.S Manually edited: bar-artificial-save-rbp.S ]] --- Credit: The observation and test file come from Jakub Jelinek, see [1]. --- Additional info: The gcc optimization is disabled for -Og and could be disabled by default, because it could add more , even indirectly for parts that w= ere compiled with gcc -Og. There seems to be a discussion about it in some meai= ling list. Nevertheless, gdb should not "error" or give up on a .cfi_undefined. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D38534 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D38534#c28 [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114116#c6 and https://patchwork.sourceware.org/project/gcc/list/?series=3D30327 [4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114116#c2 and https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57545&action=3Ddiff --=20 You are receiving this mail because: You are on the CC list for the bug.=