From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 58042@debbugs.gnu.org
Subject: bug#58042: 29.0.50; ASAN use-after-free in re_match_2_internal
Date: Wed, 05 Oct 2022 11:00:00 +0200 [thread overview]
Message-ID: <m25ygy3asv.fsf@Mini.fritz.box> (raw)
In-Reply-To: <m2a66a3erd.fsf@Mini.fritz.box> ("Gerd Möllmann"'s message of "Wed, 05 Oct 2022 09:34:30 +0200")
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> What I can see is that, apparently, redisplay got called because Emacs
>>> received a MacOS event, and did a prepare_menu_bars etc etc.
>>
>> You mean, a macOS event can be received asynchronously, and will
>> interrupt some processing in C, like inside regex-emacs.c?
>
> If it can, I don't know. But is the GC during redisplay is the one
> moving the string, that would be the consequence, I think.
>
>> If that can happen, no code in Emacs is safe, ever. I don't believe
>> this is possible: we no longer process window-system events
>> asynchronously, AFAIK, and for this very reason. But maybe macOS is
>> different? In that case, either we should change the macOS code to
>> avoid doing that, or we should have some means of blocking such
>> "interrupts" around specific code fragments, akin to block_input.
>
> Yeah. It would be good if that wouldn't happen ever, if it can.
I just got another ASAN error in a branch based on master. It looks
completely different, but I find it eye-opening for our case. Look at
this:
==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!
next prev parent reply other threads:[~2022-10-05 9:00 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 13:45 bug#58042: 29.0.50; ASAN use-after-free in re_match_2_internal Gerd Möllmann
2022-09-24 14:17 ` Gerd Möllmann
2022-09-24 14:48 ` Gerd Möllmann
2022-09-24 14:56 ` Eli Zaretskii
2022-09-24 15:08 ` Gerd Möllmann
2022-09-24 15:24 ` Eli Zaretskii
2022-09-25 5:50 ` Gerd Möllmann
2022-09-25 6:32 ` Eli Zaretskii
2022-09-25 7:06 ` Gerd Möllmann
2022-09-25 8:08 ` Eli Zaretskii
2022-09-25 8:28 ` Gerd Möllmann
2022-09-25 8:43 ` Eli Zaretskii
2022-09-26 5:13 ` Gerd Möllmann
2022-10-04 14:33 ` Gerd Möllmann
2022-10-04 16:35 ` Eli Zaretskii
2022-10-05 4:37 ` Gerd Möllmann
2022-10-05 6:16 ` Eli Zaretskii
2022-10-05 6:58 ` Gerd Möllmann
2022-10-05 7:22 ` Eli Zaretskii
2022-10-05 7:34 ` Gerd Möllmann
2022-10-05 9:00 ` Gerd Möllmann [this message]
2022-10-05 9:23 ` Eli Zaretskii
2022-10-05 10:14 ` Gerd Möllmann
2022-10-05 10:24 ` Gerd Möllmann
2022-10-05 10:43 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 10:49 ` Gerd Möllmann
2022-10-05 11:10 ` Gerd Möllmann
2022-10-05 11:15 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 11:37 ` Gerd Möllmann
2022-10-05 13:37 ` Eli Zaretskii
2022-10-05 13:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 14:09 ` Eli Zaretskii
2022-10-05 14:24 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 13:27 ` Eli Zaretskii
2022-10-05 13:31 ` Gerd Möllmann
2022-10-05 13:55 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-08 14:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-09 1:04 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-09 2:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-09 5:30 ` Eli Zaretskii
2022-10-05 10:45 ` Gerd Möllmann
2022-10-05 11:10 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 11:15 ` Gerd Möllmann
2022-10-05 11:23 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 11:35 ` Gerd Möllmann
2022-10-05 12:02 ` Gerd Möllmann
2022-10-05 12:08 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 13:40 ` Eli Zaretskii
2022-10-05 13:53 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 14:10 ` Eli Zaretskii
2022-10-05 12:05 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 12:32 ` Gerd Möllmann
2022-10-05 12:38 ` Gerd Möllmann
2022-10-05 12:49 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-05 12:48 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-06 5:20 ` Gerd Möllmann
2022-10-05 13:39 ` Eli Zaretskii
2022-10-05 13:13 ` Eli Zaretskii
2022-10-05 13:24 ` Gerd Möllmann
2022-10-05 12:59 ` Eli Zaretskii
2022-10-06 5:35 ` Gerd Möllmann
2022-10-06 6:59 ` Eli Zaretskii
2022-10-06 7:21 ` Gerd Möllmann
2022-10-06 8:08 ` Eli Zaretskii
2022-10-06 8:23 ` Gerd Möllmann
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=m25ygy3asv.fsf@Mini.fritz.box \
--to=gerd.moellmann@gmail.com \
--cc=58042@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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.