GNU bug report logs -
#56559
29.0.50; Invalid CGContextSaveState on NS
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56559 in the body.
You can then email your comments to 56559 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Thu, 14 Jul 2022 15:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gerd Möllmann <gerd.moellmann <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 14 Jul 2022 15:09:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In GNU Emacs 29.0.50 (build 1, aarch64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79))
of 2022-07-12 built on Mini.fritz.box
Repository revision: f209650e41d59356a90b5a602abc60c6783bc7b1
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description: macOS 12.4
Configured using:
'configure --with-native-compilation'
At various times, Emacs prints
2022-07-14 16:55:41.722952+0200 emacs[65244:294257] [emacs] CGContextSaveGState:
invalid context 0x0. If you want to see the backtrace, please set
CG_CONTEXT_SHOW_BACKTRACE environmental variable.
to the terminal from which it is started. Setting the env variable,
gives the backtrace
2022-07-14 16:56:29.249179+0200 emacs[65299:295037] [emacs] CGContextSetLineJoin: invalid context 0x0. Backtrace:
<+[NSBezierPath strokeRect:]+136>
<ns_draw_window_cursor+5448>
<display_and_set_cursor+4532>
<update_window_cursor+1556>
<update_cursor_in_window_tree+444>
<gui_update_cursor+100>
<ns_set_cursor_color+1140>
<gui_set_frame_parameters+15768>
<Fmodify_frame_parameters+856>
<Finternal_set_lisp_face_attribute+54152>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 02:44:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> 2022-07-14 16:55:41.722952+0200 emacs[65244:294257] [emacs] CGContextSaveGState:
> invalid context 0x0. If you want to see the backtrace, please set
> CG_CONTEXT_SHOW_BACKTRACE environmental variable.
>
> to the terminal from which it is started. Setting the env variable,
> gives the backtrace
>
> 2022-07-14 16:56:29.249179+0200 emacs[65299:295037] [emacs] CGContextSetLineJoin: invalid context 0x0. Backtrace:
> <+[NSBezierPath strokeRect:]+136>
> <ns_draw_window_cursor+5448>
> <display_and_set_cursor+4532>
> <update_window_cursor+1556>
> <update_cursor_in_window_tree+444>
> <gui_update_cursor+100>
> <ns_set_cursor_color+1140>
> <gui_set_frame_parameters+15768>
> <Fmodify_frame_parameters+856>
> <Finternal_set_lisp_face_attribute+54152>
>
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];
and if so, what the value of `ns_updating_frame' and `f' are at that
location.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 09:51:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 56559 <at> debbugs.gnu.org (full text, mbox):
> On 2022-07-15,, at 4:43 , Po Lu <luangruo <at> yahoo.com> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 09:55:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>> On 2022-07-15,, at 4:43 , Po Lu <luangruo <at> yahoo.com> 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.
Odd, I thought that message was supposed to show up if you try to draw
something without an active graphics context. I'm no Mac programmer, so
I guess someone else should take over at this point.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 10:34:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 56559 <at> debbugs.gnu.org (full text, mbox):
> On 2022-07-15,, at 11:54 , Po Lu <luangruo <at> yahoo.com> wrote:
>
> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Doesn't seem to happen.
>
> Odd, I thought that message was supposed to show up if you try to draw
> something without an active graphics context. I'm no Mac programmer, so
> I guess someone else should take over at this point.
Coming to think about it, maybe I'm doing something wrong? How would I check for nil in this case? I did "ctx == nil". Should that perhaps be "*ctx == nil"? (Sorry, I'm not an ObjC programmer at all.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 11:53:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Coming to think about it, maybe I'm doing something wrong? How would
> I check for nil in this case? I did "ctx == nil". Should that
> perhaps be "*ctx == nil"? (Sorry, I'm not an ObjC programmer at all.)
No, "ctx == nil" should be enough.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 13:07:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> In GNU Emacs 29.0.50 (build 1, aarch64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79))
> of 2022-07-12 built on Mini.fritz.box
> Repository revision: f209650e41d59356a90b5a602abc60c6783bc7b1
> Repository branch: master
> Windowing system distributor 'Apple', version 10.3.2113
> System Description: macOS 12.4
>
> Configured using:
> 'configure --with-native-compilation'
>
> At various times, Emacs prints
>
> 2022-07-14 16:55:41.722952+0200 emacs[65244:294257] [emacs] CGContextSaveGState:
> invalid context 0x0. If you want to see the backtrace, please set
> CG_CONTEXT_SHOW_BACKTRACE environmental variable.
>
> to the terminal from which it is started.
I can't reproduce this issue. Can you describe in more detail what you
do to reproduce the warning? Can you reproduce this in emacs -Q?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 13:15:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 56559 <at> debbugs.gnu.org (full text, mbox):
> On 2022-07-15,, at 15:05 , Daniel Martín <mardani29 <at> yahoo.es> wrote:
>
> I can't reproduce this issue. Can you describe in more detail what you
> do to reproduce the warning? Can you reproduce this in emacs -Q?
I do nothing special, just start Emacs (with Spacemacs config). It happens when drawing a hollow box cursor in my case, which is what I found out so far.
I haven't tried with emacs -Q so far.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 13:26:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Can I please ask another question? You seem to be the only one here knowing the NS stuff.
I'm looking at the ns_focus/ns_unfocus stuff,. From just eading the code, it appears to me that nested calls liek so:
1 ns_focus in ns_draw_window_cursor
2 ns_focus in draw_.*
3 ns_unfocus in draw_.*
4 ...
5 ns_unfocus in ns_draw_window_cursor
are not supported, or is the intention that they are?
My hypthesis is the ns_unfocus in line 3 above undoes the ns_focus from line 1, or parts thereof, I haven't checked that thoroughly.
To make that a theory, I've added an ns_focus like so
ns_focus(f, NULL, 0);
[NSBezierPath strokeRect:NSInsetRect(r, 0.5, 0.5)];
and voilà the error is gone.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 14:03:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 56559 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Can I please ask another question? You seem to be the only one here
> knowing the NS stuff.
There's also Alan Third (alan <at> idocy.org), and the developers listed in
etc/NEXTSTEP. They know the code much better than I do.
> I'm looking at the ns_focus/ns_unfocus stuff,. From just eading the
> code, it appears to me that nested calls liek so:
>
> 1 ns_focus in ns_draw_window_cursor
> 2 ns_focus in draw_.*
> 3 ns_unfocus in draw_.*
> 4 ...
> 5 ns_unfocus in ns_draw_window_cursor
>
> are not supported, or is the intention that they are?
They are not indeed.
> My hypthesis is the ns_unfocus in line 3 above undoes the ns_focus
> from line 1, or parts thereof, I haven't checked that thoroughly.
>
> To make that a theory, I've added an ns_focus like so
>
> ns_focus(f, NULL, 0);
> [NSBezierPath strokeRect:NSInsetRect(r, 0.5, 0.5)];
>
> and voilà the error is gone.
Thanks. Does what I just installed on master work too? (I can't test
on macOS ATM, but it works on GNUstep.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#56559
; Package
emacs
.
(Fri, 15 Jul 2022 14:13:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 56559 <at> debbugs.gnu.org (full text, mbox):
> On 2022-07-15,, at 16:01 , Po Lu <luangruo <at> yahoo.com> wrote:
>
> Thanks. Does what I just installed on master work too? (I can't test
> on macOS ATM, but it works on GNUstep.)
>
Works for me. Thanks!
P.S.
For posterity, because I will forget: One can set a breakpoint at CGPostError in maxOS to stop when such an error occurs.
Reply sent
to
Po Lu <luangruo <at> yahoo.com>
:
You have taken responsibility.
(Sat, 16 Jul 2022 03:06:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Gerd Möllmann <gerd.moellmann <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 16 Jul 2022 03:06:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 56559-done <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Works for me. Thanks!
Great, then I'm closing this bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 13 Aug 2022 11:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 309 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.