From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Errors building from master with a clean repository Date: Mon, 22 Apr 2019 17:31:44 -0700 Organization: UCLA Computer Science Department Message-ID: <84279731-9572-de3c-4806-a7c52fb79fee@cs.ucla.edu> References: <87ef5z9l23.fsf@gmail.com> <7db3cae7-794c-83d6-b8f4-f0ec000d1674@cs.ucla.edu> <83o951b29x.fsf@gnu.org> <58b59f1d-94ee-cffc-f711-b4fdcdb0b471@cs.ucla.edu> <83a7gi8ovg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1063424B16A604EAC0C76A7F" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="155065"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: agrambot@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 23 02:32:00 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIjLr-000eBv-FS for ged-emacs-devel@m.gmane.org; Tue, 23 Apr 2019 02:31:59 +0200 Original-Received: from localhost ([127.0.0.1]:46078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIjLq-0004dE-AY for ged-emacs-devel@m.gmane.org; Mon, 22 Apr 2019 20:31:58 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIjLj-0004d7-IN for emacs-devel@gnu.org; Mon, 22 Apr 2019 20:31:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIjLh-0004c9-OF for emacs-devel@gnu.org; Mon, 22 Apr 2019 20:31:51 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hIjLf-0004ac-UP; Mon, 22 Apr 2019 20:31:48 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3452A16182F; Mon, 22 Apr 2019 17:31:46 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jtLll1zi53hu; Mon, 22 Apr 2019 17:31:45 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1B8A3161831; Mon, 22 Apr 2019 17:31:45 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id g3kOkENVJTMY; Mon, 22 Apr 2019 17:31:44 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C744C16171B; Mon, 22 Apr 2019 17:31:44 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH In-Reply-To: <83a7gi8ovg.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235791 Archived-At: This is a multi-part message in MIME format. --------------1063424B16A604EAC0C76A7F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 4/22/19 12:45 AM, Eli Zaretskii wrote: > > You have consistently removed the references to -gdwarf-N compiler > option, presumably on the assumption that GCC nowadays automatically > uses the highest supported version? No, I was merely assuming that -gdwarf-4 is good enough to debug Emacs; -gdwarf-5 is still marked as "experimental" in GCC 8's doc, and I haven't used -gdwarf-5. If there's a significant advantage to using -gdwarf-5 then discussion of it should be added to etc/DEBUG. In the meantime I tried to improve the wording about this, in the attached patch. > I think this section could greatly benefit from a short explanation > what "undefined behavior" means, or a couple of examples of it. It's hard to be brief as -fsanitize=undefined is a bit tricky, but I took a shot at it by installing the attached. --------------1063424B16A604EAC0C76A7F Content-Type: text/x-patch; name="0001-Improve-UBSan-discussion-in-etc-DEBUG.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Improve-UBSan-discussion-in-etc-DEBUG.patch" >From afaab7395ddae3f6db79f2e9c46f8dfc83444b5e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 22 Apr 2019 17:26:11 -0700 Subject: [PATCH] Improve UBSan discussion in etc/DEBUG * etc/DEBUG: Improve -gdwarf-N documentation. Go into more detail about UndefinedBehaviorSanitizer. --- etc/DEBUG | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/etc/DEBUG b/etc/DEBUG index 717553871a..836e820e4a 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -181,10 +181,10 @@ Good luck! ** When you are trying to analyze failed assertions or backtraces, it is essential to compile Emacs with flags suitable for debugging. -With GCC 4.8 or later, you can invoke 'make' with CFLAGS="-O0 -g3". -With older GCC, you can use CFLAGS="-O0 -g3 -gdwarf-4", replacing "4" -by the highest version of DWARF that your compiler supports; -with non-GCC compilers, "-O0 -g3" may be the best you can do. +Although CFLAGS="-O0 -g3" often suffices with modern compilers, +you may benefit further by using CFLAGS="-O0 -g3 -gdwarf-4", replacing +"4" by the highest version of DWARF that your compiler supports; +this is especially important for GCC versions older than 4.8. With GCC and higher optimization levels such as -O2, the -fno-omit-frame-pointer and -fno-crossjumping options are often essential. The latter prevents GCC from using the same abort call for @@ -917,13 +917,26 @@ setting the new-console option before running Emacs under GDB: ** Running Emacs with undefined-behavior sanitization -Building Emacs with undefined-behavior sanitization can help debug -integer overflow and other undefined behavior in C code. To use -UndefinedBehaviorSanitizer with GCC and similar compilers, append -'-fsanitize=undefined' to CFLAGS, either when running 'configure' or -running 'make'. For example: +Building Emacs with undefined-behavior sanitization can help find +several kinds of low-level problems in C code, including: - ./configure CFLAGS='-O0 -g3 -fsanitize=undefined' + * Out-of-bounds access of many (but not all) arrays. + * Signed integer overflow, e.g., (INT_MAX + 1). + * Integer shifts by a negative or wider-than-word value. + * Misaligned pointers and pointer overflow. + * Loading a bool or enum value that is out of range for its type. + * Passing NULL to or returning NULL from a function requiring nonnull. + * Passing a size larger than the corresponding array to memcmp etc. + * Passing invalid values to some builtin functions, e.g., __builtin_clz (0). + * Reaching __builtin_unreachable calls (in Emacs, 'eassume' failure). + +To use UndefinedBehaviorSanitizer with GCC and similar compilers, +append '-fsanitize=undefined' to CFLAGS, either when running +'configure' or running 'make'. When supported, you can also specify +'bound-strict' and 'float-cast-overflow'. For example: + + ./configure \ + CFLAGS='-O0 -g3 -fsanitize=undefined,bounds-strict,float-cast-overflow' You may need to append '-static-libubsan' to CFLAGS if your version of GCC is installed in an unusual location. @@ -940,9 +953,10 @@ program. ** Running Emacs with address sanitization Building Emacs with address sanitization can help debug memory-use -problems. To use AddressSanitizer with GCC and similar compilers, -append '-fsanitize=address' to CFLAGS, either when running 'configure' -or running 'make'. Configure, build and run Emacs with +problems, such as freeing the same object twice. To use +AddressSanitizer with GCC and similar compilers, append +'-fsanitize=address' to CFLAGS, either when running 'configure' or +running 'make'. Configure, build and run Emacs with ASAN_OPTIONS='detect_leaks=0' in the environment to suppress diagnostics of minor memory leaks in Emacs. For example: -- 2.20.1 --------------1063424B16A604EAC0C76A7F--