From: "Mattias Engdegård" <mattiase@acm.org>
To: jrm@ftfl.ca
Cc: Paul Eggert <eggert@cs.ucla.edu>, 37006@debbugs.gnu.org
Subject: bug#37006: 27.0.50; garbage collection not happening after 26de2d42
Date: Sun, 11 Aug 2019 18:23:28 +0200 [thread overview]
Message-ID: <24BB9DB5-D832-462F-A03C-5595A80B6973@acm.org> (raw)
In-Reply-To: <5075406D-6DB8-4560-BB64-7198526FCF9F@acm.org>
[-- Attachment #1: Type: text/plain, Size: 572 bytes --]
Observed on macOS as well. Reason: free_cons has the condition
if (INT_ADD_WRAPV (consing_until_gc, sizeof *ptr, &consing_until_gc))
which will return true (overflow) if consing_until_gc is negative, which is kind of defensible since sizeof is unsigned which causes the sum (consing_until_gc + sizeof *ptr) to be a large unsigned number that doesn't fit into consing_until_gc.
Clang 10 defines __GNUC__ to 4 which causes intprops.h to not use __builtin_add_overflow despite that being present and working.
Casting the sizeof should fix it; patch attached.
[-- Attachment #2: 0001-Avoid-unsigned-addend-in-overflow-check-bug-37006.patch --]
[-- Type: application/octet-stream, Size: 989 bytes --]
From f733339714cab022cbbdea06148795d452b183fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sun, 11 Aug 2019 18:11:54 +0200
Subject: [PATCH] Avoid unsigned addend in overflow check (bug#37006)
* src/alloc.c (free_cons): Cast addend to avoid spurious overflow when
consing_until_gc is negative.
---
src/alloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/alloc.c b/src/alloc.c
index 5e089311a2..d416d32743 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2542,7 +2542,8 @@ free_cons (struct Lisp_Cons *ptr)
ptr->u.s.u.chain = cons_free_list;
ptr->u.s.car = dead_object ();
cons_free_list = ptr;
- if (INT_ADD_WRAPV (consing_until_gc, sizeof *ptr, &consing_until_gc))
+ if (INT_ADD_WRAPV (consing_until_gc, (object_ct) sizeof *ptr,
+ &consing_until_gc))
consing_until_gc = OBJECT_CT_MAX;
gcstat.total_free_conses++;
}
--
2.20.1 (Apple Git-117)
next parent reply other threads:[~2019-08-11 16:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5075406D-6DB8-4560-BB64-7198526FCF9F@acm.org>
2019-08-11 16:23 ` Mattias Engdegård [this message]
2019-08-11 17:07 ` bug#37006: 27.0.50; garbage collection not happening after 26de2d42 Eli Zaretskii
[not found] ` <83h86nu0pq.fsf@gnu.org>
[not found] ` <86pnlbphus.fsf@phe.ftfl.ca>
2019-08-12 2:31 ` Eli Zaretskii
2019-08-12 14:34 ` Joseph Mingrone
2019-08-12 16:49 ` Eli Zaretskii
2019-08-12 17:00 ` Mattias Engdegård
2019-08-13 15:37 ` Eli Zaretskii
2019-08-13 16:48 ` Mattias Engdegård
2019-08-13 17:04 ` Eli Zaretskii
2019-08-13 17:29 ` Mattias Engdegård
2019-08-13 17:21 ` Paul Eggert
2019-08-13 17:53 ` Eli Zaretskii
2019-08-13 19:32 ` Paul Eggert
2019-08-14 16:06 ` Eli Zaretskii
2019-08-15 1:37 ` Paul Eggert
2019-08-15 14:17 ` Eli Zaretskii
2019-08-15 18:51 ` Paul Eggert
2019-08-15 19:34 ` Eli Zaretskii
2019-09-14 7:51 ` Paul Eggert
2019-09-14 8:30 ` Eli Zaretskii
2019-08-11 12:39 Joseph Mingrone
2019-08-11 15:13 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=24BB9DB5-D832-462F-A03C-5595A80B6973@acm.org \
--to=mattiase@acm.org \
--cc=37006@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=jrm@ftfl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.