From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#58042: 29.0.50; ASAN use-after-free in re_match_2_internal Date: Wed, 05 Oct 2022 14:32:07 +0200 Message-ID: References: <83edvnv965.fsf@gnu.org> <83pmf6u76i.fsf@gnu.org> <83mtaau43p.fsf@gnu.org> <83ilkytyif.fsf@gnu.org> <87y1tuv851.fsf@yahoo.com> <87lepuv5l8.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Cc: Eli Zaretskii , 58042@debbugs.gnu.org, Alan Third To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 05 14:35:24 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 1og3cS-0007Bw-8E for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Oct 2022 14:35:24 +0200 Original-Received: from localhost ([::1]:46046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1og3cJ-0007FT-Hz for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Oct 2022 08:35:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og3aA-0007Ci-Sr for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 08:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1og3aA-0006UM-Kq for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 08:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1og3aA-0002jx-Et for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 08:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Oct 2022 12:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58042 X-GNU-PR-Package: emacs Original-Received: via spool by 58042-submit@debbugs.gnu.org id=B58042.166497313910480 (code B ref 58042); Wed, 05 Oct 2022 12:33:02 +0000 Original-Received: (at 58042) by debbugs.gnu.org; 5 Oct 2022 12:32:19 +0000 Original-Received: from localhost ([127.0.0.1]:56173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1og3ZS-0002iy-Q5 for submit@debbugs.gnu.org; Wed, 05 Oct 2022 08:32:19 -0400 Original-Received: from mail-ej1-f54.google.com ([209.85.218.54]:35572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1og3ZP-0002ik-W7 for 58042@debbugs.gnu.org; Wed, 05 Oct 2022 08:32:17 -0400 Original-Received: by mail-ej1-f54.google.com with SMTP id k2so5169444ejr.2 for <58042@debbugs.gnu.org>; Wed, 05 Oct 2022 05:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date; bh=2aup/3+dADtR9GD2U/aPEhVLENU5uRWaUFs7bOblFRU=; b=LlYMEXddjOCXh7xFd4Px0rV5QFcYsh4zKpHm/ULBaJ7bs1SPfsXjZSpDgAHqgQ6ZL1 p5LLCHBNTU2gkuLVUCdSwgrCYJypwd0SpbEh+Aft0vSSaieaAGu4caqHC/q8W4a/4TLA CixJSItXUBWe0igjiHs8rAfg38vcS+Mow6hFatWVjsoGsjuLpjeCEY+Kd5n6zQ+gE4EF s1ncfQ9ozJgppWpyu6ieOIIcfrW1dcU5kczDxr5hhSJvxA0oNkL4ON/oVh3Z8XAjW00w C44jLNvG5y3hu6gkfgL6Uyh8MGtYfqw2RyiSYuqJGhnWmFESCGOBvO2abepNP07ALMlB 6x4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date; bh=2aup/3+dADtR9GD2U/aPEhVLENU5uRWaUFs7bOblFRU=; b=6y373nQUhqBX1yfXpIG7pxKViRW7DYUkuEI3do5oEzt4xtf3VTwP9dSW6LhlKSMgu9 UAyzDKJUPbhYteMCJKBaZraEcxCU0m2r/4rrlala1dDs45TnqhCUb9OK2kzKVfGhfnNR K65vZdBRd1ZQy64rLA6okTDqnZJlg4iEcKWl3vPvHpEF9cYDl14R/L/hF3Gl+24Xa6zH 2jKa4PZ+GBZVUI2SgaGXek+SIQxLUTuAwfJwr7HNxgf7dL9lq2HsSCoEq0E9N3X874lG bgFkXnolQqNknRLss7UDiGiK/2UpeS96//MJ1QmzwPEH5C2S/4sa3lMXWBag3ZFyemv8 HxhA== X-Gm-Message-State: ACrzQf1iresDChF6yza+pbvB3z1Zo4o8/s9KjWdJe4TOlodVKOlMjA+T wrl2H2UGm5SLhMJZ2CKlPS6ZmMOyx2jUOg== X-Google-Smtp-Source: AMsMyM7f4Puu3BTHJwbvTJTYtmemHJ1wNoy5QWOuaQqEgBaVhmgLQUOc9N0DbG4VzFPjwKLzqLIIgA== X-Received: by 2002:a17:907:728a:b0:78d:2b4b:e7f7 with SMTP id dt10-20020a170907728a00b0078d2b4be7f7mr2527309ejc.269.1664973129511; Wed, 05 Oct 2022 05:32:09 -0700 (PDT) Original-Received: from Mini.fritz.box (pd9e36cc6.dip0.t-ipconnect.de. [217.227.108.198]) by smtp.gmail.com with ESMTPSA id n19-20020aa7c693000000b00458a03203b1sm3778734edq.31.2022.10.05.05.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 05:32:08 -0700 (PDT) In-Reply-To: <87lepuv5l8.fsf@yahoo.com> (Po Lu's message of "Wed, 05 Oct 2022 20:05:07 +0800") 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244525 Archived-At: Po Lu writes: > Gerd M=C3=B6llmann writes: > >> Po Lu writes: >> >>> I'm going to guess that window_sub_list is returning a window that was >>> not marked during GC. It's a problem that also exists with my >>> incremental garbage collector. Does this help? >>> >>> diff --git a/src/alloc.c b/src/alloc.c >>> index 419c5e558b..522925d248 100644 >>> --- a/src/alloc.c >>> +++ b/src/alloc.c >>> @@ -6634,6 +6634,9 @@ mark_window (struct Lisp_Vector *ptr) >>> mark_glyph_matrix (w->desired_matrix); >>> } >>>=20=20 >>> + if (w->next) >>> + mark_window (w->next); >>> + >>> /* Filter out killed buffers from both buffer lists >>> in attempt to help GC to reclaim killed buffers faster. >>> We can do it elsewhere for live windows, but this is the >> >> Indeed, that seems to work! > > Could you please replace that code with: > > if (!NILP (w->next) > && !vectorlike_marked_p (&XWINDOW (w->next)->header)) > emacs_abort (); > > And see if Emacs ever aborts? > > I just remembered that the old garbage collector does not work the same > way as the one in my branch, so that bug shouldn't be possible. With the change diff --git a/src/alloc.c b/src/alloc.c index 419c5e558b..4e0dd12729 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6625,6 +6625,15 @@ mark_window (struct Lisp_Vector *ptr) =20 mark_vectorlike (&ptr->header); =20 +#if 1 + if (!NILP (w->next) + && !vectorlike_marked_p (&XWINDOW (w->next)->header)) + emacs_abort (); +#else + if (!NILP (w->next)) + mark_object (w->next); +#endif + /* Mark glyph matrices, if any. Marking window matrices is sufficient because frame matrices use the same glyph memory. */ I don't get an abort, but the ASAN error again =3D=3D67682=3D=3DERROR: AddressSanitizer: heap-use-after-free on address 0x= 000107130d00 at pc 0x0001002a481c bp 0x00016fdcc3c0 sp 0x00016fdcc3b8 READ of size 8 at 0x000107130d00 thread T0 #0 0x1002a4818 in PSEUDOVECTORP lisp.h:1110 #1 0x1002a4888 in SYMBOL_WITH_POS_P lisp.h:1122 #2 0x10025a338 in EQ lisp.h:1342 #3 0x100280eb0 in run_window_change_functions window.c:3964 #4 0x1000f18c4 in redisplay_internal xdisp.c:16600 #5 0x100107bf8 in redisplay xdisp.c:16111 #6 0x10089364c in -[EmacsView layoutSublayersOfLayer:] nsterm.m:8661 #7 0x1900a9624 in CA::Layer::layout_if_needed(CA::Transaction*)+0x224 (= QuartzCore:arm64e+0x20624) #8 0x1901f661c in CA::Context::commit_transaction(CA::Transaction*, double, double*)+0x1c0 (QuartzCore:arm6 frame #8: 0x0000000100280eb4 emacs`run_window_change_functions at window.c:= 3964:7 3961 (de-)selected as its frame's or the globally selected 3962 window. */ 3963 if (((frame_selected_change -> 3964 && (EQ (window, old_selected_window) 3965 || EQ (window, selected_window))) 3966 || (frame_selected_window_change 3967 && (EQ (window, FRAME_OLD_SELECTED_WINDOW (f)) (lldb) p window (Lisp_Object) $18 =3D 0x00000001071c2935 (struct window *) $23 =3D 0x000000= 01071c2930 (lldb) p old_selected_window (Lisp_Object) $24 =3D 0x0000000107130d05 (struct Lisp_Vector *) $28 =3D 0x0= 000000107130d00 old_selected_window looks strange. It's a global that is not staticpro'd \o/