This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 00/10] Undefined Behavior Sanitizer, this time with docs
- From: John Baldwin <jhb at FreeBSD dot org>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Mon, 8 Oct 2018 12:14:34 -0700
- Subject: Re: [PATCH v2 00/10] Undefined Behavior Sanitizer, this time with docs
- References: <20181002044420.17628-1-tom@tromey.com>
On 10/1/18 9:44 PM, Tom Tromey wrote:
> This is a new version of the series to add -fsanitize=undefined to the
> build.
>
> It's only added to gdb, though it occurred to me later that it would
> probably be better to add it to all the libraries as well.
>
> This version addresses the review comments, and in particular adds
> documentation in patch #10 about performance. It also fixes a bug
> observed on the S390 builds in patch #2.
>
> Regression tested by the buildbot.
FWIW, I built GDB master today and ubsan (from LLVM, not GCC) flagged a
use of obstack_blank_fast() in minsyms.c with a negative offset (used to
shrink an obstack) when trying to do 'start' on /bin/ls:
(gdb) start
Temporary breakpoint 1 at 0x402674: file /usr/src/bin/ls/ls.c, line 161.
Starting program: /bin/ls
../../gdb/minsyms.c:1378:7: runtime error: addition of unsigned offset to 0x00080907cd10 overflowed to 0x00080907cc38
This corresponds to the invocation of obstack_blank_fast here:
/* Compact out any duplicates, and free up whatever space we are
no longer using. */
mcount = compact_minimal_symbols (msymbols, mcount, m_objfile);
obstack_blank_fast (&m_objfile->per_bfd->storage_obstack,
(mcount + 1 - alloc_count) * sizeof (struct minimal_symbol));
The case that triggered the failure for me had these values that resulted
in a negative offset:
(top-gdb) p mcount
$23 = 5740
(top-gdb) p alloc_count
$24 = 5744
...
(top-gdb) p mcount + 1 - alloc_count
$26 = -3
I guess since sizeof's return type is size_t, then the promotion rules on
LP64 mean that the resulting value is unsigned? Anyway, we might consider
making ubsan only default to on for GCC for now?
--
John Baldwin