Bug 31268 - gdb.base/unwind-on-each-insn-amd64.exp regression
Summary: gdb.base/unwind-on-each-insn-amd64.exp regression
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 15.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-19 15:42 UTC by Simon Marchi
Modified: 2024-04-24 21:12 UTC (History)
3 users (show)

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


Attachments
gdb.fail.log (with asan) (3.75 KB, text/x-log)
2024-01-20 14:52 UTC, Tom de Vries
Details
gdb.pass.log (without asan) (3.55 KB, text/x-log)
2024-01-20 14:53 UTC, Tom de Vries
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Marchi 2024-01-19 15:42:20 UTC
I see:

FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $fba_value == $fn_fba
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: check frame-id matches
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: bt 2
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: up
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $sp_value == $::main_sp
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $fba_value == $::main_fba
FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: [string equal $fid $::main_fid]


Tom Tromey said he was only able to reproduce with an ASan build, so it might be important here, even though gdb.log doesn't contain an ASan error.  The first error is:

 380 (gdb) PASS: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: get $sp and frame base for fn: get hexadecimal valueof "$sp"
 381 info frame^M
 382 Stack level 0, frame at 0x7fffffffd5a0:^M
 383  rip = 0x40112f in foo (/home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c:22); saved rip = 0x7ffff7df01ca^M
 384  called by frame at 0x7fffffffd640^M
 385  source language c.^M
 386  Arglist at 0x7fffffffd590, args: s=0x401114 <main+14> "\277\b @"^M
 387  Locals at 0x7fffffffd590, Previous frame's sp is 0x7fffffffd5a0^M
 388  Saved registers:^M
 389   rbp at 0x7fffffffd590, rip at 0x7fffffffd598^M
 390 (gdb) FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $fba_value == $fn_fba
Comment 1 Tom de Vries 2024-01-20 14:52:15 UTC
(In reply to Simon Marchi from comment #0)
> Tom Tromey said he was only able to reproduce with an ASan build

+1.
Comment 2 Tom de Vries 2024-01-20 14:52:40 UTC
Created attachment 15314 [details]
gdb.fail.log (with asan)
Comment 3 Tom de Vries 2024-01-20 14:53:06 UTC
Created attachment 15315 [details]
gdb.pass.log (without asan)
Comment 4 Tom de Vries 2024-01-21 10:43:11 UTC
Bisects to:
...
commit 528b729be1a293a21f44149351f3eba5b4e2d870
Author: Guinevere Larsen <blarsen@redhat.com>
Date:   Wed Nov 1 17:25:32 2023 +0100

    gdb/dwarf2: Add support for DW_LNS_set_epilogue_begin in line-table
...
Comment 5 Tom de Vries 2024-03-27 14:26:17 UTC
Hmm, I'm running into this now after installing package gcc-PIE on my system.

It's a hardcoded .S file, maybe nopie is required?
Comment 6 Tom de Vries 2024-03-27 14:29:07 UTC
(In reply to Tom de Vries from comment #5)
> Hmm, I'm running into this now after installing package gcc-PIE on my system.
> 
> It's a hardcoded .S file, maybe nopie is required?

Though when running with target board unix/-fPIE/-pie, it passes.
Comment 7 Tom de Vries 2024-04-01 07:56:42 UTC
This patch ( https://sourceware.org/pipermail/gdb-patches/2024-March/207709.html ) was submitted, that seems to address this PR.
Comment 8 Tom de Vries 2024-04-08 13:06:14 UTC
I'd like the fix (currently discussed on the ml) for this PR to be included in the 15.1 release.
Comment 9 Joel Brobecker 2024-04-14 18:03:51 UTC
Hi Tom,

> I'd like the fix for this PR to be included in the 15.1 release.

For the record, can you say which consideration(s?) made you reach this assessment? 

Looking at the fix, and in particular the title of the fix (out of bounds array access), I'm guessing that the out-of-bound condition is considered sufficiently critical that the fix should be in the release.
Comment 10 Tom de Vries 2024-04-15 11:48:16 UTC
(In reply to Joel Brobecker from comment #9)
> Hi Tom,
> 
> > I'd like the fix for this PR to be included in the 15.1 release.
> 
> For the record, can you say which consideration(s?) made you reach this
> assessment? 
> 
> Looking at the fix, and in particular the title of the fix (out of bounds
> array access), I'm guessing that the out-of-bound condition is considered
> sufficiently critical that the fix should be in the release.

Hi Joel,

indeed, it's the fact that's it's an out-of-bound condition.
Comment 11 Sourceware Commits 2024-04-24 14:27:02 UTC
The master branch has been updated by Bernd Edlinger <edlinger@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=63ddc8af5d7d3ad909aad66291f23507ba987bb4

commit 63ddc8af5d7d3ad909aad66291f23507ba987bb4
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date:   Tue Apr 9 09:27:52 2024 +0000

    Fix an out of bounds array access in find_epilogue_using_linetable
    
    An out of bounds array access in find_epilogue_using_linetable causes random
    test failures like these:
    
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $fba_value == $fn_fba
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: check frame-id matches
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: bt 2
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: up
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $sp_value == $::main_sp
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: $fba_value == $::main_fba
    FAIL: gdb.base/unwind-on-each-insn-amd64.exp: foo: instruction 6: [string equal $fid $::main_fid]
    
    Here the read happens below the first element of the line
    table, and the test failure depends on the value that is
    read from there.
    
    It also happens that std::lower_bound returns a pointer exactly at the upper
    bound of the line table, also here the read value is undefined, that happens
    in this test:
    
    FAIL: gdb.dwarf2/dw2-epilogue-begin.exp: confirm watchpoint doesn't trigger
    
    Fixes: 528b729be1a2 ("gdb/dwarf2: Add support for DW_LNS_set_epilogue_begin in line-table")
    
    Co-Authored-By: Tom de Vries <tdevries@suse.de>
    
    PR symtab/31268
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31268
Comment 12 Tom de Vries 2024-04-24 21:12:28 UTC
Fixed.