Subject: Re: bug#63187: 30.0.50; Tail of longer lines painted after end of nearby lines on macOS

From: Aaron Jensen <[email-masked]>
Date: Fri, 23 Jun 2023 07:54:53 -0400

On Fri, Jun 23, 2023 at 4:48 AM Alan Third <[email-masked]> wrote:
>
> On Thu, Jun 15, 2023 at 10:17:11PM -0400, Aaron Jensen wrote:
> >
> > I saw a paint issue today. The "<" to the left of the indented (and
> > redacted) lines 65-68 was an artifact. It kept painting there even
> > while scrolling until I resized the window, then they all disappeared.
> > They appeared one at a time while scrolling, as if the painting of one
> > the one on line 63 was "fixed" in the window position as I was
> > scrolling (likely it just didn't get cleared as necessary).
>
> It could be worth forcing the system to display when we want it to,
> rather than leaving it to decide itself... I don't think this will
> make any difference, but perhaps it's worth a shot.
>
> modified   src/nsterm.m
> @@ -1089,6 +1089,8 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
>    [view unlockFocus];
>  #if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400
>    [[view window] flushWindow];
> +#else
> +  [view display];
>  #endif
>
>    unblock_input ();
>
> This feels to me like things are happening out of order or
> simultaneously, but I don't really see how that could be happening.
> The drawing system throws out errors if you try to use it from sub
> threads, so it should be obvious if there was some multi-threading
> issue...

I'll try that in a bit, thanks. One interesting thing is that just
yesterday I saw this crash for the first time (with the patch I
recently posted):

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000000c0
Exception Codes:       0x0000000000000001, 0x00000000000000c0

VM Region Info: 0xc0 is not in any region.  Bytes before following
region: 105553518919488
      REGION TYPE                    START - END         [ VSIZE]
PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M]
rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib               0x191db4724 __pthread_kill + 8
1   libsystem_pthread.dylib               0x191debc28 pthread_kill + 288
2   libsystem_c.dylib                     0x191cc246c raise + 32
3   emacs                                 0x1046488c8
terminate_due_to_signal + 212 (emacs.c:464)
4   emacs                                 0x104649128 emacs_abort + 20
(sysdep.c:2320)
5   emacs                                 0x104605ad4 ns_term_shutdown
+ 144 (nsterm.m:5770)
6   emacs                                 0x1044cdcdc shut_down_emacs
+ 332 (emacs.c:3017)
7   emacs                                 0x104648890
terminate_due_to_signal + 156 (emacs.c:447)
8   emacs                                 0x1044f1a20
handle_fatal_signal + 12 (sysdep.c:1783) [inlined]
9   emacs                                 0x1044f1a20
deliver_thread_signal + 112 (sysdep.c:1775) [inlined]
10  emacs                                 0x1044f1a20
deliver_fatal_thread_signal + 128 (sysdep.c:1795)
11  emacs                                 0x1044f38e0 handle_sigsegv +
64 (sysdep.c:1888)
12  libsystem_platform.dylib             0x191e1aa24 _sigtramp + 56
13  ???                            0xffff800104607dc4 ???
14  AppKit                               0x19569b8d0
-[_NSTrackingAreaAKViewHelper
updateTrackingAreasWithInvalidCursorRects:] + 284
15  AppKit                               0x1958a8964
_NSViewSubViewMutationSafeApply + 220
16  AppKit                               0x19569b974
-[_NSTrackingAreaAKViewHelper
updateTrackingAreasWithInvalidCursorRects:] + 448
17  AppKit                               0x1958a8964
_NSViewSubViewMutationSafeApply + 220
18  AppKit                               0x19569b974
-[_NSTrackingAreaAKViewHelper
updateTrackingAreasWithInvalidCursorRects:] + 448
19  AppKit                               0x195699cb4
-[_NSTrackingAreaAKManager displayCycleUpdateStructuralRegions] + 176
20  AppKit                               0x195195658
__NSWindowGetDisplayCycleObserverForUpdateStructuralRegions_block_invoke
+ 364
21  AppKit                               0x195190c30
NSDisplayCycleObserverInvoke + 168
22  AppKit                               0x19519088c NSDisplayCycleFlush + 644
23  QuartzCore                           0x1993adce4
CA::Transaction::run_commit_handlers(CATransactionPhase) + 120
24  QuartzCore                           0x1993acaa0
CA::Transaction::commit() + 320
25  AppKit                               0x195212c7c
__62+[CATransaction(NSCATransaction)
NS_setFlushesWithDisplayLink]_block_invoke + 272
26  AppKit                               0x1958eef7c
___NSRunLoopObserverCreateWithHandler_block_invoke + 64
27  CoreFoundation                       0x191ec99f0
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
28  CoreFoundation                       0x191ec98dc
__CFRunLoopDoObservers + 532
29  CoreFoundation                       0x191ec8f14 __CFRunLoopRun + 776
30  CoreFoundation                       0x191ec84b8 CFRunLoopRunSpecific + 612
31  HIToolbox                             0x19b712c40
RunCurrentEventLoopInMode + 292
32  HIToolbox                             0x19b7128d0
ReceiveNextEventCommon + 220
33  HIToolbox                             0x19b7127d4
_BlockUntilNextEventMatchingListInModeWithFilter + 76
34  AppKit                               0x1950e9d44 _DPSNextEvent + 636
35  AppKit                               0x1950e8ee0
-[NSApplication(NSEvent)
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
36  AppKit                               0x1950dd344 -[NSApplication run] + 464
37  emacs                                 0x104605c24 -[EmacsApp run]
+ 264 (nsterm.m:5823)
38  emacs                                 0x10461842c ns_read_socket_1
+ 560 (nsterm.m:4703)
39  emacs                                 0x10461602c ns_flush_display
+ 44 (nsterm.m:5311)
40  emacs                                 0x104428a04 flush_frame + 32
(frame.h:1760) [inlined]
41  emacs                                 0x104428a04
echo_area_display + 1080 (xdisp.c:13203)
42  emacs                                 0x1044284d8 message3_nolog +
548 (xdisp.c:12104)
43  emacs                                 0x104428078 message3 + 132
(xdisp.c:12034)
44  emacs                                 0x10455456c Fmessage + 68
(editfns.c:3192)
45  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
46  emacs                                 0x10455f750 Fapply + 996 (eval.c:2679)
47  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
48  subr--trampoline-6d657373616765_message_0.eln        0x1196f7f20
F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_0 + 88
49  magit-process-0a318d45-3f4ff10f.eln        0x128a6262c
F6d616769742d72756e2d6769742d6173796e63_magit_run_git_async_0 + 220
50  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
51  magit-fetch-8acc7b48-029daf61.eln        0x12acf664c
F6d616769742d6769742d6665746368_magit_git_fetch_0 + 104
52  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
53  magit-fetch-8acc7b48-029daf61.eln        0x12acf6abc
F6d616769742d66657463682d616c6c_magit_fetch_all_0 + 76
54  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
55  emacs                                 0x1045a8a0c exec_byte_code +
3236 (bytecode.c:809)
56  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
57  emacs                                 0x10455a760 eval_sub + 2356
(eval.c:2483)
58  emacs                                 0x104560e50 Fprogn + 28
(eval.c:436) [inlined]
59  emacs                                 0x104560e50 funcall_lambda +
1356 (eval.c:3246)
60  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
61  emacs                                 0x1045a8a0c exec_byte_code +
3236 (bytecode.c:809)
62  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
63  emacs                                 0x104557b14
Ffuncall_interactively + 68 (callint.c:250)
64  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
65  emacs                                 0x104559000
Fcall_interactively + 5332 (callint.c:342)
66  simple-fab5b0cf-e1c8f2a9.eln         0x107dd4efc
F636f6d6d616e642d65786563757465_command_execute_0 + 652
67  emacs                                 0x10455ca4c Ffuncall + 396
(eval.c:3008)
68  emacs                                 0x1044d1bbc call1 + 20
(lisp.h:3241) [inlined]
69  emacs                                 0x1044d1bbc command_loop_1 +
1384 (keyboard.c:1504)
70  emacs                                 0x10455d7fc
internal_condition_case + 96 (eval.c:1486)
71  emacs                                 0x1044d1640 command_loop_2 +
52 (keyboard.c:1133)
72  emacs                                 0x10455d09c internal_catch +
88 (eval.c:1209)
73  emacs                                 0x104648d1c
command_loop.cold.1 + 80 (keyboard.c:1111)
74  emacs                                 0x1044d0d74 command_loop +
156 (keyboard.c:1110)
75  emacs                                 0x1044d0c2c recursive_edit_1
+ 152 (keyboard.c:720)
76  emacs                                 0x1044d0fe0 Frecursive_edit
+ 372 (keyboard.c:803)
77  emacs                                 0x1044cfdb4 main + 8324 (emacs.c:2530)
78  dyld                                 0x191a93f28 start + 2236