From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58975: 29.0.50; noverlay fails to build with --enable-checking=structs Date: Thu, 03 Nov 2022 02:17:16 +0200 Message-ID: <874jvg3n8z.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40052"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Matt Armstrong , Stefan Monnier To: 58975@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 03 01:18:22 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqNw5-000AC8-Qw for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Nov 2022 01:18:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqNvt-0001NK-Ah; Wed, 02 Nov 2022 20:18:10 -0400 Original-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 ) id 1oqNvq-0001ND-8w for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 20:18:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oqNvo-0007cS-Fz for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 20:18:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oqNvm-0008Rc-Hn; Wed, 02 Nov 2022 20:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: matt@rfc20.org, monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Nov 2022 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58975 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Matt Armstrong , Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.166743465932419 (code B ref -1); Thu, 03 Nov 2022 00:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Nov 2022 00:17:39 +0000 Original-Received: from localhost ([127.0.0.1]:47389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqNvN-0008Qn-TP for submit@debbugs.gnu.org; Wed, 02 Nov 2022 20:17:39 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqNvL-0008Qf-EY for submit@debbugs.gnu.org; Wed, 02 Nov 2022 20:17:37 -0400 Original-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 ) id 1oqNvL-0001Ih-9d for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 20:17:35 -0400 Original-Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oqNvG-0007Zd-US for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 20:17:34 -0400 Original-Received: by mail-ed1-x534.google.com with SMTP id r14so759013edc.7 for ; Wed, 02 Nov 2022 17:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=Qm4VuW+FhlnxooIrf56tpVlVIuAFRJB5Jk2kOV+dfTQ=; b=Y1UZLHrMcrx1XIwd2OcTOGSV+DsbnitK1f2pQkagUFiUEz0KQ1Xh6MdH6TtGLI9bMF 0dvMwxxUBSq9zEwlRDV4g7yZYo+sNw474hKCSeZn8oeneTHdGlmWSKD4qJnBlqs/fgIz qBFm9rzZKEqDvhGUq1cbAGDPVwODRPgLm62CuDK0kloVcYGeBpJYBo3TetHw02KpbeB0 Zq341MxQEe0dfguGd6S3msxoXdKKEDjGLyIDbHVWhn12ZBdvVWs7Rae6qIuriuRb8ytt DVrmpA7SZ8zQQVlXFV4KKZp5sh5cJME/JJMr/zsLXLC5ZCaDqgP9FTKgsrk+XJm9V1V1 0xWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Qm4VuW+FhlnxooIrf56tpVlVIuAFRJB5Jk2kOV+dfTQ=; b=doI4LbeP9HnZqU4/X1zlAqbghryciZwa1NLUQHIFoo1MLVZZcTe+VZVvUvwHZSl7jO Rh7bKXvHifB4CIuMubZ79bAtUTJyc/kAXJwS6iIRrvIwPjJhzU/fSbR7OWfX0leMYNtq uhtLPt7eif0MqObHHq4ZMCj2nVBGsLyqhTydR6Vq8OXHM4j0cGr15dCu1XN13dSsfLSz 7XP4gScNq7vqCMpI3x/vbZXxBmTnh64GwAKDR+JKSu+iePiqACXShyMlQ6z/ngWc52dW hVP7XLVR8YdfkRDVB8jgxP0mEPZ1E9kBGk72GBVnmb9LbTVKsSuGWwa+aET+amaQyjuC VX0g== X-Gm-Message-State: ACrzQf3xfPMzMKO7PvMAtycr1TgGWYPKlzh75alQzckr0hmsygcqX9w+ 5tzIBf2SOqcRFifxabtKsWsX27W2gZdMMQ== X-Google-Smtp-Source: AMsMyM50glwzen8gqa2LW5i4mG2X3logNBg67X8X04AcNdOCooCOwF/kPbGn+9181oI/Jha7wHvbJA== X-Received: by 2002:a50:fe01:0:b0:463:10fd:943d with SMTP id f1-20020a50fe01000000b0046310fd943dmr24128453edt.314.1667434639607; Wed, 02 Nov 2022 17:17:19 -0700 (PDT) Original-Received: from localhost ([2a02:587:320c:8829:23:8156:16ed:40c2]) by smtp.gmail.com with ESMTPSA id g11-20020a170906394b00b007abafe43c3bsm5945722eje.86.2022.11.02.17.17.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 17:17:18 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=contovob@tcd.ie; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246902 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Tags: patch With HEAD as commit 05f5d978ae of 2022-11-02 "Initialize child signal handling before posix_spawn too.": $ git clean -fdx && ./autogen.sh all \ && ./configure --enable-checking=3Dstructs && make The last step fails with: --8<---------------cut here---------------start------------->8--- CC pdumper.o pdumper.c: In function =E2=80=98dump_interval_node=E2=80=99: pdumper.c:2141:3: error: #error "interval_node changed. See CHECK_STRUCTS c= omment in config.h." 2141 | # error "interval_node changed. See CHECK_STRUCTS comment in config= .h." | ^~~~~ pdumper.c: In function =E2=80=98dump_overlay=E2=80=99: pdumper.c:2183:3: error: #error "Lisp_Overlay changed. See CHECK_STRUCTS co= mment in config.h." 2183 | # error "Lisp_Overlay changed. See CHECK_STRUCTS comment in config.= h." | ^~~~~ pdumper.c: In function =E2=80=98dump_buffer=E2=80=99: pdumper.c:2752:3: error: #error "buffer changed. See CHECK_STRUCTS comment = in config.h." 2752 | # error "buffer changed. See CHECK_STRUCTS comment in config.h." | ^~~~~ --8<---------------cut here---------------end--------------->8--- Is this the right fix? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Port-interval-trees-to-enable-checking-structs.patch >From a9edc07fb02de3252384285be058217cce6d4d55 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 2 Nov 2022 03:50:38 +0200 Subject: [PATCH] Port interval trees to --enable-checking=structs Some names under the interval_* namespace were renamed under the itree_* namespace in commits: 0. f421b58db5 of 2022-10-19 "Prefix all itree.h type names with itree_". 1. 37a1145410 of 2022-10-19 "Rename all exported itree.h functions with the itree_ prefix" Further, some values still referenced in commentary were removed in commits: 2. 258e618364 of 2022-10-17 "Delete the itree_null sentinel node, use NULL everywhere." 3. 2c4a3910b3 of 2022-10-02 "itree: Use a single iterator object" * src/alloc.c (mark_overlay): * src/buffer.c (set_overlays_multibyte): * src/itree.h (ITREE_FOREACH): * src/itree.c (itree_create, itree_destroy): Update commentaries. (interval_stack_ensure_space, itree_insert_gap): Prefer unsigned-to-unsigned comparisons over signed-to-unsigned. (interval_stack_push_flagged, interval_tree_insert) (itree_iterator_start, itree_iterator_finish, itree_iterator_next) (itree_iterator_narrow): Improve assertions. (itree_init): Warn about memory leak in commentary. (interval_tree_init): Complete renames of interval_tree -> itree_tree and interval_tree_clear -> itree_clear. (interval_tree_remove_fix): Fix indentation. * src/pdumper.c [CHECK_STRUCTS] (dump_interval_node): Use the correct name in the HASH condition and #error message. (dump_overlay, dump_buffer): Update HASH. --- src/alloc.c | 2 +- src/buffer.c | 2 +- src/itree.c | 39 ++++++++++++++++++++------------------- src/itree.h | 2 +- src/pdumper.c | 8 ++++---- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index f69c65dedc..6862cf916f 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6508,7 +6508,7 @@ mark_char_table (struct Lisp_Vector *ptr, enum pvec_type pvectype) static void mark_overlay (struct Lisp_Overlay *ov) { - /* We don't mark the `interval_node` object, because it is managed manually + /* We don't mark the `itree_node` object, because it is managed manually rather than by the GC. */ eassert (BASE_EQ (ov->interval->data, make_lisp_ptr (ov, Lisp_Vectorlike))); set_vectorlike_marked (&ov->header); diff --git a/src/buffer.c b/src/buffer.c index 3129aa2890..3b0e6f1f9a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -982,7 +982,7 @@ set_overlays_multibyte (bool multibyte) struct itree_tree *tree = current_buffer->overlays; const intmax_t size = itree_size (tree); - /* We can't use `interval_node_set_region` at the same time + /* We can't use `itree_node_set_region` at the same time as we iterate over the itree, so we need an auxiliary storage to keep the list of nodes. */ USE_SAFE_ALLOCA; diff --git a/src/itree.c b/src/itree.c index bd4e8cc574..e29533c81d 100644 --- a/src/itree.c +++ b/src/itree.c @@ -191,7 +191,7 @@ interval_stack_clear (struct interval_stack *stack) } static inline void -interval_stack_ensure_space (struct interval_stack *stack, intmax_t nelements) +interval_stack_ensure_space (struct interval_stack *stack, uintmax_t nelements) { if (nelements > stack->size) { @@ -207,7 +207,7 @@ interval_stack_ensure_space (struct interval_stack *stack, intmax_t nelements) interval_stack_push_flagged (struct interval_stack *stack, struct itree_node *node, bool flag) { - eassert (node && node != NULL); + eassert (node); /* FIXME: While the stack used in the iterator is bounded by the tree depth and could be easily pre-allocated to a large enough size to avoid @@ -290,6 +290,7 @@ itree_iterator_create (struct itree_tree *tree) static void itree_init (void) { + /* FIXME: this leaks! */ iter = itree_iterator_create (NULL); } @@ -555,13 +556,13 @@ itree_node_end (struct itree_tree *tree, return node->end; } -/* Allocate an interval_tree. Free with interval_tree_destroy. */ +/* Allocate an itree_tree. Free with itree_destroy. */ struct itree_tree * itree_create (void) { - /* FIXME? Maybe avoid the initialization of itree_null in the same - way that is used to call mem_init in alloc.c? It's not really + /* FIXME? Maybe avoid the initialization of iter in the same way + that is used to call mem_init in alloc.c? It's not really important though. */ itree_init (); @@ -584,10 +585,10 @@ itree_clear (struct itree_tree *tree) /* Initialize a pre-allocated tree (presumably on the stack). */ static void -interval_tree_init (struct interval_tree *tree) +interval_tree_init (struct itree_tree *tree) { - interval_tree_clear (tree); - /* tree->iter = itree_iterator_create (tree); */ + itree_clear (tree); + /* iter = itree_iterator_create (tree); */ } #endif @@ -596,8 +597,8 @@ interval_tree_init (struct interval_tree *tree) itree_destroy (struct itree_tree *tree) { eassert (tree->root == NULL); - /* if (tree->iter) - * itree_iterator_destroy (tree->iter); */ + /* if (iter) + * itree_iterator_destroy (iter); */ xfree (tree); } @@ -775,7 +776,7 @@ interval_tree_insert_fix (struct itree_tree *tree, static void interval_tree_insert (struct itree_tree *tree, struct itree_node *node) { - eassert (node->begin <= node->end && node != NULL); + eassert (node && node->begin <= node->end); /* FIXME: The assertion below fails because `delete_all_overlays` doesn't set left/right/parent to NULL. */ /* eassert (node->left == NULL && node->right == NULL @@ -912,7 +913,7 @@ interval_tree_remove_fix (struct itree_tree *tree, if (parent == NULL) eassert (node == tree->root); else - eassert (node == NULL || node->parent == parent); + eassert (node == NULL || node->parent == parent); while (parent != NULL && null_safe_is_black (node)) { @@ -1151,7 +1152,7 @@ itree_iterator_start (struct itree_tree *tree, ptrdiff_t begin, ptrdiff_t end, enum itree_order order, const char *file, int line) { - /* struct itree_iterator *iter = tree->iter; */ + eassert (iter); if (iter->running) { fprintf (stderr, @@ -1179,7 +1180,7 @@ itree_iterator_start (struct itree_tree *tree, ptrdiff_t begin, void itree_iterator_finish (struct itree_iterator *iter) { - eassert (iter->running); + eassert (iter && iter->running); iter->running = false; } @@ -1212,7 +1213,7 @@ itree_insert_gap (struct itree_tree *tree, && (node->begin != node->end || node->rear_advance)) interval_stack_push (saved, node); } - for (int i = 0; i < saved->length; ++i) + for (size_t i = 0; i < saved->length; ++i) itree_remove (tree, nav_nodeptr (saved->nodes[i])); /* We can't use an iterator here, because we can't effectively @@ -1352,7 +1353,7 @@ interval_node_intersects (const struct itree_node *node, struct itree_node * itree_iterator_next (struct itree_iterator *g) { - eassert (g->running); + eassert (g && g->running); struct itree_node *const null = NULL; struct itree_node *node; @@ -1424,9 +1425,9 @@ itree_iterator_next (struct itree_iterator *g) itree_iterator_narrow (struct itree_iterator *g, ptrdiff_t begin, ptrdiff_t end) { - eassert (g->running); + eassert (g && g->running); eassert (begin >= g->begin); eassert (end <= g->end); - g->begin = max (begin, g->begin); - g->end = min (end, g->end); + g->begin = max (begin, g->begin); + g->end = min (end, g->end); } diff --git a/src/itree.h b/src/itree.h index c6b68d3667..1f8143a3e7 100644 --- a/src/itree.h +++ b/src/itree.h @@ -147,7 +147,7 @@ #define ITREE_H BEWARE: - The expression T may be evaluated more than once, so make sure - it is cheap a pure. + it is cheap and pure. - Only a single iteration can happen at a time, so make sure none of the code within the loop can start another tree iteration, i.e. it shouldn't be able to run ELisp code, nor GC since GC can run ELisp by way diff --git a/src/pdumper.c b/src/pdumper.c index d6ae57afb2..0a5d96dbb7 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2137,8 +2137,8 @@ dump_marker (struct dump_context *ctx, const struct Lisp_Marker *marker) dump_interval_node (struct dump_context *ctx, struct itree_node *node, dump_off parent_offset) { -#if CHECK_STRUCTS && !defined (HASH_interval_node_5765524F7E) -# error "interval_node changed. See CHECK_STRUCTS comment in config.h." +#if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13) +# error "itree_node changed. See CHECK_STRUCTS comment in config.h." #endif struct itree_node out; dump_object_start (ctx, &out, sizeof (out)); @@ -2179,7 +2179,7 @@ dump_interval_node (struct dump_context *ctx, struct itree_node *node, static dump_off dump_overlay (struct dump_context *ctx, const struct Lisp_Overlay *overlay) { -#if CHECK_STRUCTS && !defined (HASH_Lisp_Overlay_1CD4249AEC) +#if CHECK_STRUCTS && !defined (HASH_Lisp_Overlay_EB4C05D8D2) # error "Lisp_Overlay changed. See CHECK_STRUCTS comment in config.h." #endif START_DUMP_PVEC (ctx, &overlay->header, struct Lisp_Overlay, out); @@ -2748,7 +2748,7 @@ dump_hash_table (struct dump_context *ctx, static dump_off dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) { -#if CHECK_STRUCTS && !defined HASH_buffer_F0F08347A5 +#if CHECK_STRUCTS && !defined HASH_buffer_193CAA5E45 # error "buffer changed. See CHECK_STRUCTS comment in config.h." #endif struct buffer munged_buffer = *in_buffer; -- 2.35.1 --=-=-= Content-Type: text/plain BTW, every time itree_create is called via add_buffer_overlay, it in turn calls itree_init, which calls itree_iterator_create, which xmallocs a new itree_iterator, interval_stack, and itree_nodes. Is this memory leak going to rust my computer? Should I open a ticket for this? Thanks, -- Basil In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2022-10-31 built on tia Repository revision: ea388b7f3ab995423aa90980f7c530884ea1c5a4 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure 'CFLAGS=-Og -ggdb3' -C --prefix=/home/blc/.local --enable-checking=structs --with-file-notification=yes --with-x-toolkit=lucid --with-x' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_IE.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix --=-=-=--