Paul Eggert <eggert@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at submit) by debbugs.gnu.org; 16 Jul 2024 23:26:47 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 16 19:26:47 2024 Received: from localhost ([127.0.0.1]:34589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sTrZG-0007Yd-L3 for submit <at> debbugs.gnu.org; Tue, 16 Jul 2024 19:26:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:32864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1sTrZD-0007YV-Lf for submit <at> debbugs.gnu.org; Tue, 16 Jul 2024 19:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eggert@HIDDEN>) id 1sTrZA-0000wL-I9 for bug-gnu-emacs@HIDDEN; Tue, 16 Jul 2024 19:26:40 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eggert@HIDDEN>) id 1sTrZ7-0005YK-Sj for bug-gnu-emacs@HIDDEN; Tue, 16 Jul 2024 19:26:40 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 8BB833C0140A4 for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jul 2024 16:26:34 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id Ubewo4EMCe2t for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jul 2024 16:26:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 0052A3C00E415 for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jul 2024 16:26:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 0052A3C00E415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1721172394; bh=O/7zlizyeCfQ0/3DE45/vBaM3P+ufZRqJcXbspM82sI=; h=Message-ID:Date:MIME-Version:To:From; b=RA1Y2BYlnRuzV+JYmRY5TDakxJlGnCkLaPDDMYTBAILsVlFnKddqhHelFIUZG7NWf IqrqSi7o1A9LegM9vnJgbHcGXCDUxe08XLHbEuoGnmJyLSAooSz1JslIjANDEIGq6+ SA8ZlRNR2LIXYuLwXCtXfv20svjOPZRh/bQwKTDr5bdxw93CY7VrSDUQV1ZZad7Ald Xse2l/M9axLmNJKpu/hxCL11LwOflvVKAAgWf9gqjKGDpaSIe7EMzGu3yHQaAMcoyv 5HX5yDQSI3TH1AH37Jp2LBDPcBVFJkczTgIJdhPz6PWNzhd5XCYsgNmPaBZ4MGN/qw GyCa8MsJx4E2A== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id EJDzkBBsJDzt for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jul 2024 16:26:33 -0700 (PDT) Received: from [192.168.254.12] (unknown [47.154.17.165]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id DAAE83C0140A4 for <bug-gnu-emacs@HIDDEN>; Tue, 16 Jul 2024 16:26:33 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------ACQdPPR23JeukjDZuA8EIuWr" Message-ID: <e7c67465-1734-48c8-82bb-6b96eee4e167@HIDDEN> Date: Tue, 16 Jul 2024 16:26:33 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Emacs bug reports and feature requests <bug-gnu-emacs@HIDDEN> From: Paul Eggert <eggert@HIDDEN> Subject: rare Emacs screwups on x86 due to GCC bug 58416 Organization: UCLA Computer Science Department Received-SPF: pass client-ip=131.179.128.66; envelope-from=eggert@HIDDEN; helo=mail.cs.ucla.edu X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------ACQdPPR23JeukjDZuA8EIuWr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit While testing GNU Emacs built on Fedora 40 with gcc (GCC) 14.1.1 20240607 (Red Hat 14.1.1-5) with -m32 for x86 and configured --with-wide-int, I discovered that Emacs misbehaved in a hard-to-debug way due to GCC bug 58416. This bug causes GCC to generate wrong x86 machine instructions when a C program accesses a union containing a 'double'. The bug I observed is that if you have something like this: union u { double d; long long int i; } u; then GCC sometimes generates x86 instructions that copy u.i by using fldl/fstpl instruction pairs to push the 64-bit quantity onto the 387 floating point stack, and then pop the stack into another memory location. Unfortunately the fldl/fstpl trick fails in the unusual case when the bit pattern of u.i, when interpreted as a double, is a NaN, as that can cause the fldl/fstpl pair to store a different NaN with a different bit pattern, which means the destination integer disagrees with u.i. The bug is obscure, since the bug's presence depends on the GCC version, on the optimization options used, on the exact source code, and on the exact integer value at runtime (the value is typically copied correctly even when GCC has generated the incorrect machine code, since most long long int values don't alias with NaNs). In short the bug appears to be rare. Here are some possible courses of action: * Do nothing and hope x86 users won't run into this rare bug. * Have the GCC folks fix the bug. However, given that the bug has been reported for over a decade multiple times without a fix, it seems that fixing it is too difficult and/or too low priority for this aging platform. Also, even if the bug is fixed in future GCC the bug will still be present with people using older GCC. * Build with Clang or some other compiler instead. We should be encouraging GCC, though. * Rewrite Emacs to never use 'double' (or 'float' or 'long double') inside a union. This could be painful and hardly seems worthwhile. * When using GCC to build Emacs on x86, compile with safer options that make the bug impossible. The attached proposed patch does that, by telling GCC not to use the 387 stack. (This patch fixed the Emacs misbehavior in my experimental build.) The downside is that the resulting Emacs executables need SSE2, introduced for the Pentium 4 in 2000 <https://en.wikipedia.org/wiki/SSE2>. Nowadays few users need to run Emacs on non-SSE2 x86, so this may be good enough. Also, the proposed patch gives the builder an option to compile Emacs without the safer options, for people who want to build for older Intel-compatible platforms and who don't mind an occasional wrong answer or crash. --------------ACQdPPR23JeukjDZuA8EIuWr Content-Type: text/x-patch; charset=UTF-8; name="0001-Work-around-GCC-bug-58416-when-building-for-x86.patch" Content-Disposition: attachment; filename*0="0001-Work-around-GCC-bug-58416-when-building-for-x86.patch" Content-Transfer-Encoding: base64 RnJvbSBiNmM2YzA1NDU2MDc2ODdlMzZmYzQ3ZTVkNTA3OWFlYzRmNThkNTkxIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEV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DaGFuZ2VzIGluIEVtYWNzIDMxLjEKIAorKiogV2hlbiB1c2luZyBHQ0MgdG8gYnVpbGQg RW1hY3Mgb24gMzItYml0IHg4NiBzeXN0ZW1zLCAnY29uZmlndXJlJyBub3cKK2RlZmF1bHRz IHRvIHNwZWNpZnlpbmcgdGhlIEdDQyBvcHRpb25zIC1tc3NlMiBhbmQgLW1mcG1hdGg9c3Nl IHRvIHdvcmsKK2Fyb3VuZCBHQ0MgYnVnIDU4NDE2LiAgQXMgYSByZXN1bHQsIHRoZSByZXN1 bHRpbmcgRW1hY3MgZXhlY3V0YWJsZSBub3cKK3JlcXVpcmVzIHN1cHBvcnQgZm9yIFNTRTIs IGludHJvZHVjZWQgYnkgSW50ZWwgaW4gMjAwMCBmb3IgdGhlIFBlbnRpdW0gNAorYW5kIGJ5 IEFNRCBpbiAyMDAzIGZvciB0aGUgT3B0ZXJvbiBhbmQgQXRobG9uIDY0LiAgVG8gYnVpbGQg RW1hY3Mgd2l0aAorR0NDIGZvciBvbGRlciB4ODYgcHJvY2Vzc29ycywgcGFzcyAnZW1hY3Nf Y3ZfZ2NjX2J1Z181ODQxNl9DRkxBR1M9bm8nIHRvCisnY29uZmlndXJlJzsgYWx0aG91Z2gg dGhlIHJlc3VsdGluZyBFbWFjcyBtYXkgZ2VuZXJhdGUgaW5jb3JyZWN0IHJlc3VsdHMKK29y IGR1bXAgY29yZSwgYW55IHN1Y2ggbWlzYmVoYXZpb3Igc2hvdWxkIGJlIHJhcmUuCisKIAwK ICogU3RhcnR1cCBDaGFuZ2VzIGluIEVtYWNzIDMxLjEKIAotLSAKMi40NS4yCgo= --------------ACQdPPR23JeukjDZuA8EIuWr--
Paul Eggert <eggert@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#72145
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.