Re: [patch] Disable child VMA randomizations

Eli Zaretskii
2008-06-08T10:39:19Z

> Date: Sun, 8 Jun 2008 11:42:13 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org, Andreas Schwab <schwab@suse.de>
>
> > > +Standalone programs run with the randomization enabled by default."),
> >
> > On some platforms, right?
>
> Fixed.
>
> Standalone programs run with the\n\
> +randomization enabled by default on the GNU/Linux platform."),

I think "on some platforms" is better, as we won't need to update the
list each time another platform adds support for it. (Btw, doesn't
Windows Vista already do that?)

> > > +get assigned differently on each run some subtle bugs may be reproducible only
> > > +with specially assigned addresses possibly not reachable with the default
> > > +setting of @kbd{set disable-randomization on}.
> >
> > Can you explain this sentence? I'd like to suggest a better wording,
> > but I can't do that unless I understand what is it that you are trying
> > to say here.
>
> New text:
>
> As some debuggee's
> +bugs may depend on the assigned addresses the default @value{GDBN} behavior of
> +disabling the randomization may make some debuggee's bugs unreproducible. You
> +may want to run the debuggee many times with the randomization enabled (and
> +thus this option disabled) to catch such kind of bugs. Correctly written
> +programs must run the same way notwithstanding this configuration option.

I suggest this modified text:

Some bugs rear their ugly heads only when the program is loaded at
certain addresses. If your bug disappears when you run the program
under @value{GDBN}, that might be because @value{GDBN} by default
disables the address randomization on platforms, such as
@sc{gnu}/Linux, which do that for stand-alone programs. Use
@kbd{set disable-randomization off} to try to reproduce such elusive
bugs.

> > > +PIE executables (type @code{ET_DYN}, compiled by @code{gcc -fPIE -pie}) have
> > > +randomized everything - the executable base address, shared libraries base
> > > +address (their prelinking is ignored), mmap areas, stack and heap. Regular
> > > +executables (type @code{ET_EXEC}) do not have randomized their base address,
> > > +shared libraries base address is ranomized only for non-prelinked libraries,
> > > +mmap, stack and heap are still randomized.
> >
> > There's too much unexplained technical details here, so much so that
> > this paragraph sounds like it was meant only for the initiated.
>
> It is mostly explained at:
> http://lwn.net/Articles/190139/
>
> I expected the full explanation is inappropriate for the GDB manual but I tried
> to include it in this patch:

Thanks. It needs a bit more work, but now that I understand the
issues, I can do it myself. Go ahead and commit the doco patch, and I
will revisit it when I have time.

> +The virtual address space randomization is implemented only on @sc{gnu}/Linux.

Btw, according to the above URL, this is not true: it says that
OpenBSD and Adamantix (whatever that is) have it as well.