Subject: bug#56559: 29.0.50; Invalid CGContextSaveState on NS

From: Gerd Möllmann <[email-masked]>
Date: Fri, 15 Jul 2022 11:50:02 +0200

> On 2022-07-15,, at 4:43 , Po Lu <[email-masked]> wrote:
> 
> 
> Could you please try to find out if `ctx' is ever nil here (in
> ns_draw_window_cursor):
> 
>  ns_focus (f, NULL, 0);
> 
> ->NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
>  [ctx saveGraphicsState];

Doesn't seem to happen.

> 
> and if so, what the value of `ns_updating_frame' and `f' are at that
> location.
> 
> Thanks.

Maybe this helps: I've got a backtrace with

  <+[NSBezierPath strokeRect:]+264>
   <ns_draw_window_cursor+1188>

and the disassembly of ns_draw_window_cursor in the vicinity of that offset shows

    0x10045a824 <+1088>: bl     0x10008a184               ; draw_phys_cursor_glyph at xdisp.c:32617
    0x10045a828 <+1092>: adrp   x8, 230
    0x10045a82c <+1096>: ldr    x8, [x8, #0x10]
    0x10045a830 <+1100>: str    x8, [sp]
    0x10045a834 <+1104>: ldur   d0, [x29, #-0x60]
    0x10045a838 <+1108>: ldur   d1, [x29, #-0x58]
    0x10045a83c <+1112>: ldur   d2, [x29, #-0x50]
    0x10045a840 <+1116>: ldur   d3, [x29, #-0x48]
    0x10045a844 <+1120>: fmov   d5, #0.50000000
    0x10045a848 <+1124>: mov.16b v4, v5
    0x10045a84c <+1128>: bl     0x1004bf6c4               ; symbol stub for: NSInsetRect
    0x10045a850 <+1132>: ldr    x0, [sp]
    0x10045a854 <+1136>: add    x8, sp, #0x20
    0x10045a858 <+1140>: str    d0, [sp, #0x20]
    0x10045a85c <+1144>: str    d1, [sp, #0x28]
    0x10045a860 <+1148>: add    x8, x8, #0x10
    0x10045a864 <+1152>: str    d2, [sp, #0x30]
    0x10045a868 <+1156>: str    d3, [x8, #0x8]
    0x10045a86c <+1160>: adrp   x8, 229
    0x10045a870 <+1164>: ldr    x1, [x8, #0x6e0]
    0x10045a874 <+1168>: ldr    d0, [sp, #0x20]
    0x10045a878 <+1172>: ldr    d1, [sp, #0x28]
    0x10045a87c <+1176>: ldr    d2, [sp, #0x30]
    0x10045a880 <+1180>: ldr    d3, [sp, #0x38]
    0x10045a884 <+1184>: bl     0x1004c0894               ; symbol stub for: objc_msgSend
    0x10045a888 <+1188>: b      0x10045a918               ; <+1332> at nsterm.m:3129:4
    0x10045a88c <+1192>: ldur   d0, [x29, #-0x60]
    0x10045a890 <+1196>: ldur   d1, [x29, #-0x58]
    0x10045a894 <+1200>: ldur   d2, [x29, #-0x50]
    0x10045a898 <+1204>: ldur   d3, [x29, #-0x48]
    0x10045a89c <+1208>: bl     0x1004bf724               ; symbol stub for: NSRectFill
    0x10045a8a0 <+1212>: b      0x10045a918               ; <+1332> at nsterm.m:3129:4
    0x10045a8a4 <+1216>: ldur   q0, [x29, #-0x60]
    0x10045a8a8 <+1220>: stur   q0, [x29, #-0x80]
    0x10045a8ac <+1224>: ldur   q0, [x29, #-0x50]
    0x10045a8b0 <+1228>: stur   q0, [x29, #-0x70]
    0x10045a8b4 <+1232>: ldur   x0, [x29, #-0x18]
    0x10045a8b8 <+1236>: bl     0x100100a90               ; get_phys_cursor_glyph at window.c:7420
    0x10045a8bc <+1240>: str    x0, [sp, #0x88]
    0x10045a8c0 <+1244>: ldr    x8, [sp, #0x88]
    0x10045a8c4 <+1248>: ldr    w8, [x8, #0x18]
    0x10045a8c8 <+1252>: tbz    w8, #0xa, 0x10045a900     ; <+1308> at nsterm.m:3125:7
    0x10045a8cc <+1256>: b      0x10045a8d0               ; <+1260> at nsterm.m:3123:23