From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66755 invoked by alias); 8 Oct 2018 19:14:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 66743 invoked by uid 89); 8 Oct 2018 19:14:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=Compact, HContent-Transfer-Encoding:8bit X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Oct 2018 19:14:39 +0000 Received: from John-Baldwins-MacBook-Pro-2.local (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 3CDCF10AFCD; Mon, 8 Oct 2018 15:14:37 -0400 (EDT) Subject: Re: [PATCH v2 00/10] Undefined Behavior Sanitizer, this time with docs To: Tom Tromey , gdb-patches@sourceware.org References: <20181002044420.17628-1-tom@tromey.com> From: John Baldwin Message-ID: <8df7a2b9-800a-5a70-1075-e687145c9394@FreeBSD.org> Date: Mon, 08 Oct 2018 19:14:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181002044420.17628-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00183.txt.bz2 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                                                                            Â