From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#58042: 29.0.50; ASAN use-after-free in re_match_2_internal Date: Wed, 05 Oct 2022 12:23:20 +0300 Message-ID: <83ilkytyif.fsf@gnu.org> References: <83edvnv965.fsf@gnu.org> <83pmf6u76i.fsf@gnu.org> <83mtaau43p.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19770"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58042@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 05 11:25:32 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 1og0ei-000519-8J for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Oct 2022 11:25:32 +0200 Original-Received: from localhost ([::1]:35920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1og0eh-0003d3-A8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Oct 2022 05:25:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og0dJ-0002xK-1v for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 05:24:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1og0dH-0003yf-AV for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 05:24:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1og0dG-0003YI-FW for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2022 05:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Oct 2022 09:24: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.166496183013635 (code B ref 58042); Wed, 05 Oct 2022 09:24:02 +0000 Original-Received: (at 58042) by debbugs.gnu.org; 5 Oct 2022 09:23:50 +0000 Original-Received: from localhost ([127.0.0.1]:55871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1og0d4-0003Xr-DK for submit@debbugs.gnu.org; Wed, 05 Oct 2022 05:23:50 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1og0d2-0003Xd-4f for 58042@debbugs.gnu.org; Wed, 05 Oct 2022 05:23:49 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og0cw-0003vU-Us; Wed, 05 Oct 2022 05:23:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=c3TSQ1xVUrp12rsmAIiehz01btu4dGQZ4BzCMC3IKo0=; b=sMWrR6VGYTuWYSL5Tpde ZbcrKg9n0Q2CcqSlALLbpiCpsetn8VnxZ5xHhT8oWpyQhuDFBGnmRSLj4cDrb8+k45/LnBFrC2Imk IveNkclzD3gpdYUZzqpl98ZZaq9/s9EJ5Uvq0OlIuGAUhbm7woL/ReUAslDgfW+qEzy1cJTUSSyR+ qcOXwg2N6u1hWURH2WmS63sTUUxFMweV2RpvcRj428cem+xr+ENAZjGZ2PNhGk6oUsuzQ+PZHvC4s qhlwefI5RHQaT8rUGDGNi2rg4P3JKm1uUFHrxeCp41DP65LbUIEixr8qepybL9W99sVtcNZf4t0re MMB70xPjCaieLw==; Original-Received: from [87.69.77.57] (port=3766 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og0ce-0002Zq-Up; Wed, 05 Oct 2022 05:23:40 -0400 In-Reply-To: (message from Gerd =?UTF-8?Q?M=C3=B6llmann?= on Wed, 05 Oct 2022 11:00:00 +0200) 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:244500 Archived-At: > From: Gerd Möllmann > Cc: 58042@debbugs.gnu.org > Date: Wed, 05 Oct 2022 11:00:00 +0200 > > ==45724==ERROR: AddressSanitizer: heap-use-after-free on address 0x000107130d00 at pc 0x0001002a4b04 bp 0x00016fd155e0 sp 0x00016fd155d8 > READ of size 8 at 0x000107130d00 thread T0 > #0 0x1002a4b00 in PSEUDOVECTORP lisp.h:1110 > #1 0x1002a4b70 in SYMBOL_WITH_POS_P lisp.h:1122 > #2 0x10025a620 in EQ lisp.h:1342 > #3 0x100281198 in run_window_change_functions window.c:3964 > #4 0x1000f1bac in redisplay_internal xdisp.c:16600 > #5 0x100107ee0 in redisplay xdisp.c:16111 > #6 0x10089366c 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:arm64e+0x16d61c) > #9 0x19008b4c8 in CA::Transaction::commit()+0x2bc (QuartzCore:arm64e+0x24c8) > #10 0x18bee1698 in __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke+0x12c (AppKit:arm64e+0x1ac698) > #11 0x18c646754 in ___NSRunLoopObserverCreateWithHandler_block_invoke+0x3c (AppKit:arm64e+0x911754) > #12 0x1892101a0 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+0x20 (CoreFoundation:arm64e+0x841a0) > #13 0x18920fff0 in __CFRunLoopDoObservers+0x24c (CoreFoundation:arm64e+0x83ff0) > #14 0x18920f524 in __CFRunLoopRun+0x300 (CoreFoundation:arm64e+0x83524) > #15 0x18920ea80 in CFRunLoopRunSpecific+0x254 (CoreFoundation:arm64e+0x82a80) > #16 0x191e4e334 in RunCurrentEventLoopInMode+0x120 (HIToolbox:arm64e+0x32334) > #17 0x191e4dfc0 in ReceiveNextEventCommon+0x140 (HIToolbox:arm64e+0x31fc0) > #18 0x191e4de64 in _BlockUntilNextEventMatchingListInModeWithFilter+0x44 (HIToolbox:arm64e+0x31e64) > #19 0x18bd76518 in _DPSNextEvent+0x358 (AppKit:arm64e+0x41518) > #20 0x18bd74e10 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0x52c (AppKit:arm64e+0x3fe10) > #21 0x18bd66fdc in -[NSApplication run]+0x250 (AppKit:arm64e+0x31fdc) > #22 0x100870bd0 in -[EmacsApp run] nsterm.m:5799 > #23 0x1008c7b2c in ns_read_socket_1 nsterm.m:4679 > #24 0x1008ae550 in ns_read_socket nsterm.m:4697 > #25 0x100437394 in gobble_input keyboard.c:7379 > #26 0x100438bfc in handle_async_input keyboard.c:7610 > #27 0x100438bdc in process_pending_signals keyboard.c:7624 > #28 0x10064bd90 in probably_quit eval.c:1657 > #29 0x10065fe6c in maybe_quit lisp.h:3737 > #30 0x10066cb7c in Fmemq fns.c:1837 > #31 0x100645de8 in FletX eval.c:936 > > There is a path from maybe_quit to redisplay, and didn't we have > maybe_quit alreasy in the matcher code? Mind-boggling! Ouch! This seems to be macOS-specific, though. So I guess we should do this dance around calls to maybe_quit in regex-emacs.c: specpdl_ref gc_count = inhibit_garbage_collection (); maybe_quit (); unbind_to (gc_count, Qnil); Or maybe even better, do this inside probably_quit (because who knows how many other callers of maybe_quit could be hit by this unexpected GC)? Can you try this?