Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	gdb-patches@sourceware.org
Cc: Luis <luis.machado.foss@gmail.com>
Subject: Re: [PATCH] gdb/testsuite: make gdb.dwarf2/dw2-empty-inline-ranges.exp work when ASLR can't be disabled
Date: Fri, 6 Feb 2026 09:56:29 -0500	[thread overview]
Message-ID: <068592e1-0817-4ef4-9605-da51ffdfb495@simark.ca> (raw)
In-Reply-To: <87bji2dkng.fsf@redhat.com>



On 2026-02-06 09:14, Andrew Burgess wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
> 
>> A colleague that goes by the name "Luis Machado" reported a failure when
>> running gdb.dwarf2/dw2-empty-inline-ranges.exp.  After investigation, we
>> found that the conditions for the test to fail are:
>>
>>  - running in an environment where GDB can't disable address space
>>    randomization (such as in a container where that capability is
>>    removed)
>>
>>  - a toolchain generating position-independent executables
>>
>> The test does a first run to grab the addresses of a few labels defined
>> in the source file.  It then crafts the DWARF using these addresses.
>> And then it does a second run for the actual test stuff.
>>
>> When the executable is PIE and ASLR is active, then the addresses in
>> both runs don't agree, which the test doesn't expect.
>>
>> It is possible to emulate the failure by inserting some:
>>
>>     gdb_test_no_output "set disable-randomization off"
>>
>> after both "prepare_for_testing" calls.  The (first) failure then
>> manifests as:
>>
>>     FAIL: gdb.dwarf2/dw2-empty-inline-ranges.exp: dwarf_version=4: empty_loc=start: entry_pc_type=empty: stopped at entry-pc
>>
>> This test compares the expected stop PC "entry_pc" with the actual stop
>> PC "pc".  In my example run, they were indeed different:
>>
>>     pc       = 0x5603ec67a159
>>     entry_pc = 0x55baba6a9159
>>
>> The simplest way to fix this, which this patch implements, is to use
>> "nopie" when building the binaries.  I don't think this affects the
>> effectiveness of the test.
>>
>> Also, in the first run, it is longer necessary to run the inferior
>> before grabbing the addresses, they are going to be the same with a
>> non-PIE executable.  So remove that.
> 
> Thanks for fixing this.  LGTM.
> 
> Approved-By: Andrew Burgess <aburgess@redhat.com>
> 
> 
> Thanks,
> Andrew
> 

Thanks, pushed.  I actually added a small comment in the test file to
explain why we use nopie.

Simon

      reply	other threads:[~2026-02-06 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 20:42 Simon Marchi
2026-02-06 14:14 ` Andrew Burgess
2026-02-06 14:56   ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=068592e1-0817-4ef4-9605-da51ffdfb495@simark.ca \
    --to=simark@simark.ca \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@gmail.com \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox