[Bug ipa/120987] [13 Regression] gdb build with lto triggers use after free since r12-5541-g2cadaa1f134bec

"vries at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 14:03:37 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D120987

--- Comment #43 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #38)
> (In reply to Richard Biener from comment #37)
> > Should be fixed on trunk.  Tom, can you confirm?
> >=20
> > I'll take care of backporting together with the other fix in the same
> > function.
>=20
> As mentioned before, the problem doesn't triggers with GCC 15.1 and later
> for the original trigger setup: the gdb build.
>=20
> So I took test-2.c (naming it test.c here) from this PR, and on Tumbleweed
> did:
> ...
> $ g++-14 --version
> g++-14 (SUSE Linux) 14.3.1 20260202 [revision
> ed5f89a2062002f5dfb69aac8cb36c629d091105]
>=20
> $ g++-15 --version
> g++-15 (SUSE Linux) 15.2.1 20260202
>=20
> $ g++-16 --version
> g++-16 (SUSE Linux) 16.0.1 20260318 (experimental)
>=20
> $ for n in 0 1 2; do g++-14 test.c -O$n; ./a.out ; echo $?; done
> 0
> 1
> 1
>=20
> $ for n in 0 1 2; do g++-15 test.c -O$n; ./a.out ; echo $?; done
> 0
> 1
> 1
>=20
> $ for n in 0 1 2; do g++-16 test.c -O$n; ./a.out ; echo $?; done
> 0
> 0
> 0
>=20
> $
> ...
>=20
> That confirms that the problem indeed is fixed on GCC trunk, while still
> reproducing for those particular g++ 14/15 versions (so I'm assuming they
> don't have the fix yet).=20
>=20

Those now pass with g++14/15/16, for both test.c and test-2.c.

> I've just checked out gdb trunk, reverted the workaround patch, build gdb
> with g++ 14 using the script listed in comment 0, and the problem still
> reproduces.
>=20
> So, once g++-14 is fixed, I could try the gdb build again.

I've tried the gdb build with the following configurations:
- 16.3, g++-14: doesn't reproduce
- trunk with workaround reverted, g++-14: doesn't reproduce
- trunk with workaround reverted, g++-16: doesn't reproduce
- 17.2 with workaround reverted, g++-14: doesn't reproduce
- 17.2 with workaround reverted, g++-16: doesn't reproduce

I think that confirms that as far as this bug report is concerned, it's fix=
ed.

The gdb PR just got reopened, so we'll have to look into that.=