Subject: Re: bug#65843: 28.2; Too many iconified frames in .emacs.desktop -> crash (macOS)

From: Gerd Möllmann <[email-masked]>
Date: Sun, 10 Sep 2023 20:40:49 +0200

Alan Third <[email-masked]> writes:

> On Sun, Sep 10, 2023 at 05:37:17PM +0200, Gerd Möllmann wrote:
>> Christian Tanzer <[email-masked]> writes:
>> 
>> > Weirder and weirder …
>> 
>> Wait a moment...  I just got this
>> 
>> [emacs-29] gerd@Mini 2023-09-10 17:24 
>> ~/emacs/29/src/ > ~/emacs/29/src/emacs -Q --eval '(desktop-read "~/bug-sowieso")' 
>> objc[88769]: autorelease pool page 0x11b4a5000 corrupted
>>   magic     0x00000000 0x00000000 0x00000000 0x00000000
>>   should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341
>>   pthread   0x201892080
>>   should be 0x201892080
>> 
>> Fatal error 6: Aborted
>
> I've a vague memory that I've seen something like this before and it
> was a runaway loop corrupting the heap...

Sometimes one just has to be lucky enough :-).
This is with the "-g -O2" build.

Does this tell you anything?

Process 70647 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1ec70)
    frame #0: 0x00000001a6475c20 libobjc.A.dylib`objc_msgSend + 32
libobjc.A.dylib`objc_msgSend:
->  0x1a6475c20 <+32>: ldr    x10, [x16, #0x10]
    0x1a6475c24 <+36>: lsr    x11, x10, #48
    0x1a6475c28 <+40>: and    x10, x10, #0xffffffffffff
    0x1a6475c2c <+44>: and    w12, w1, w11

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1ec70)
    frame #0: 0x00000001a6475c20 libobjc.A.dylib`objc_msgSend + 32
  * frame #1: 0x00000001aa2f4420 AppKit`-[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 608
    frame #2: 0x00000001aa2f4728 AppKit`-[NSWindow _reallyDoOrderWindow:] + 80
    frame #3: 0x00000001aa2fd5f0 AppKit`-[NSWindow(NSWindow_Theme) _finishMinimizeToDock] + 188
    frame #4: 0x00000001a9c42f84 AppKit`_NSCGSDockMessageReceive + 460
    frame #5: 0x00000001b01646a8 HIToolbox`DockCallback(unsigned int, unsigned int, void*, void*) + 1528
    frame #6: 0x00000001ac0793f0 HIServices`_DCXTransactionComplete + 56
    frame #7: 0x00000001ac07938c HIServices`_XTransactionComplete + 60
    frame #8: 0x00000001ac06a52c HIServices`mshMIGPerform + 204
    frame #9: 0x00000001a68eebcc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #10: 0x00000001a68eeaec CoreFoundation`__CFRunLoopDoSource1 + 520
    frame #11: 0x00000001a68ed4cc CoreFoundation`__CFRunLoopRun + 2240
    frame #12: 0x00000001a68ec4b8 CoreFoundation`CFRunLoopRunSpecific + 612
    frame #13: 0x00000001ac07930c HIServices`waitForTransaction + 196
    frame #14: 0x00000001aa2f5aa8 AppKit`minimizeItems + 120
    frame #15: 0x00000001aa2fcce4 AppKit`-[NSWindow(NSWindow_Theme) _regularMinimizeToDock] + 60
    frame #16: 0x00000001aa2fcd24 AppKit`-[NSWindow(NSWindow_Theme) _minimizeToDockBypassingWindowManager] + 36
    frame #17: 0x00000001aa478f3c AppKit`__75-[NSWMWindowCoordinator clientWindowManager:windowMiniaturizationResponse:]_block_invoke + 424
    frame #18: 0x00000001aa47959c AppKit`___NSMainRunLoopPerformBlockInModes_block_invoke + 44
    frame #19: 0x00000001a68ee1d4 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
    frame #20: 0x00000001a68ee0e8 CoreFoundation`__CFRunLoopDoBlocks + 364
    frame #21: 0x00000001a68ecf38 CoreFoundation`__CFRunLoopRun + 812
    frame #22: 0x00000001a68ec4b8 CoreFoundation`CFRunLoopRunSpecific + 612
    frame #23: 0x00000001b013edf0 HIToolbox`RunCurrentEventLoopInMode + 292
    frame #24: 0x00000001b013eaa8 HIToolbox`ReceiveNextEventCommon + 260
    frame #25: 0x00000001b013e984 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #26: 0x00000001a9b1397c AppKit`_DPSNextEvent + 636
    frame #27: 0x00000001a9b12b18 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
    frame #28: 0x000000010052e0d4 emacs`ns_send_appdefined(value=-1) at nsterm.m:4569:24 [opt]
    frame #29: 0x000000010053e8e4 emacs`-[EmacsView resizeWithOldSuperviewSize:](self=<unavailable>, _cmd=<unavailable>, oldSize=<unavailable>) at nsterm.m:7799:3 [opt]
    frame #30: 0x00000001a9b5b05c AppKit`-[NSView resizeSubviewsWithOldSize:] + 360
    frame #31: 0x00000001a9b3f53c AppKit`-[NSView setFrameSize:] + 1136
    frame #32: 0x00000001a9b59670 AppKit`-[NSWindow _oldPlaceWindow:fromServer:] + 612
    frame #33: 0x00000001a9b586f8 AppKit`-[NSWindow _setFrameCommon:display:fromServer:] + 1832
    frame #34: 0x00000001005488b4 emacs`-[EmacsWindow setFrame:display:](self=<unavailable>, _cmd=<unavailable>, windowFrame=<unavailable>, displayViews=<unavailable>) at nsterm.m:9722:3 [opt]
    frame #35: 0x0000000100548a90 emacs`-[EmacsWindow setFrame:display:animate:](self=<unavailable>, _cmd=<unavailable>, windowFrame=<unavailable>, displayViews=<unavailable>, performAnimation=<unavailable>) at nsterm.m:9733:3 [opt]
    frame #36: 0x00000001a9bf7bd4 AppKit`-[NSThemeFrame _growWindowReshapeContentAndToolbarView:withOldToolbarFrameSize:animate:] + 928
    frame #37: 0x00000001a9bf7664 AppKit`-[NSThemeFrame _reshapeContentAndToolbarView:withOldToolbarFrameSize:resizeWindow:animate:] + 200
    frame #38: 0x00000001a9bdd11c AppKit`-[NSThemeFrame _showHideToolbar:resizeWindow:animate:] + 196
    frame #39: 0x00000001a9bcf0cc AppKit`-[NSWindow _showToolbar:animate:] + 140
    frame #40: 0x00000001a9bcf00c AppKit`-[NSToolbar _show:animate:] + 80
    frame #41: 0x00000001a9bcef98 AppKit`-[NSToolbar _toggleShown:animate:] + 88
    frame #42: 0x00000001a9bcc798 AppKit`-[NSWindow setToolbar:] + 396
    frame #43: 0x0000000100546154 emacs`-[EmacsWindow createToolbar:](self=0x00000001065cb500, _cmd=<unavailable>, f=0x0000000122dd3ff0) at nsterm.m:9206:3 [opt]
    frame #44: 0x000000010053fedc emacs`-[EmacsView initFrameFromEmacs:](self=0x000000010859d880, _cmd=<unavailable>, f=0x0000000122dd3ff0) at nsterm.m:7945:3 [opt]
    frame #45: 0x0000000100564764 emacs`Fx_create_frame(parms=0x0000000106b98723) at nsfns.m:1485:3 [opt]
    frame #46: 0x00000001003baea8 emacs`funcall_subr(subr=0x00000001006d1000, numargs=<unavailable>, args=<unavailable>) at eval.c:3034:15 [opt]
    frame #47: 0x0000000100466be0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:809:14 [opt]
    frame #48: 0x00000001003bbca8 emacs`funcall_lambda [inlined] fetch_and_exec_byte_code(fun=0x0000000107218df5, args_template=257, nargs=1, args=0x0000000108604de8) at eval.c:3081:10 [opt]
    frame #49: 0x00000001003bbc7c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3153:9 [opt]
    frame #50: 0x00000001003ba9fc emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at lisp.h:0:10 [opt] [artificial]
    frame #51: 0x00000001003b0eec emacs`Ffuncall(nargs=<unavailable>, args=<unavailable>) at eval.c:2995:21 [opt]
    frame #52: 0x00000001003b800c emacs`Fapply(nargs=2, args=0x0000000108604de0) at eval.c:0 [opt]
    frame #53: 0x00000001003bac84 emacs`funcall_subr(subr=0x00000001006c5180, numargs=<unavailable>, args=<unavailable>) at eval.c:3059:9 [opt]
    frame #54: 0x0000000100466be0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:809:14 [opt]
    frame #55: 0x00000001003bbca8 emacs`funcall_lambda [inlined] fetch_and_exec_byte_code(fun=0x000000011744dbc5, args_template=512, nargs=1, args=0x000000016fdfdf60) at eval.c:3081:10 [opt]
    frame #56: 0x00000001003bbc7c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3153:9 [opt]
    frame #57: 0x00000001003b79f0 emacs`apply_lambda(fun=<unavailable>, args=<unavailable>, count=<unavailable>) at eval.c:3103:9 [opt]
    frame #58: 0x00000001003a9800 emacs`eval_sub(form=<unavailable>) at eval.c:2545:12 [opt]
    frame #59: 0x00000001003b7414 emacs`Feval(form=0x0000000106b26753, lexical=<unavailable>) at eval.c:2361:28 [opt]
    frame #60: 0x00000001003bad84 emacs`funcall_subr(subr=0x00000001006c5120, numargs=<unavailable>, args=<unavailable>) at eval.c:3036:15 [opt]
    frame #61: 0x0000000100466be0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:809:14 [opt]
    frame #62: 0x00000001003bbca8 emacs`funcall_lambda [inlined] fetch_and_exec_byte_code(fun=0x000000010700eecd, args_template=0, nargs=0, args=0x000000016fdfe700) at eval.c:3081:10 [opt]
    frame #63: 0x00000001003bbc7c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3153:9 [opt]
    frame #64: 0x00000001003b79f0 emacs`apply_lambda(fun=<unavailable>, args=<unavailable>, count=<unavailable>) at eval.c:3103:9 [opt]
    frame #65: 0x00000001003a9800 emacs`eval_sub(form=<unavailable>) at eval.c:2545:12 [opt]
    frame #66: 0x00000001003b7414 emacs`Feval(form=0x00000001077ea123, lexical=<unavailable>) at eval.c:2361:28 [opt]
    frame #67: 0x000000010028c5f0 emacs`top_level_2 at keyboard.c:1142:10 [opt] [artificial]
    frame #68: 0x00000001003b3718 emacs`internal_condition_case(bfun=(emacs`top_level_2 at keyboard.c:1141), handlers=<unavailable>, hfun=(emacs`cmd_error at keyboard.c:936)) at eval.c:1474:25 [opt]
    frame #69: 0x000000010028c568 emacs`top_level_1(ignore=0x0000000000000000) at keyboard.c:1150:5 [opt]
    frame #70: 0x00000001003b20d0 emacs`internal_catch(tag=0x000000000000eee0, func=(emacs`top_level_1 at keyboard.c:1147), arg=0x0000000000000000) at eval.c:1197:25 [opt]
    frame #71: 0x000000010025e12c emacs`command_loop at keyboard.c:1110:2 [opt]
    frame #72: 0x000000010025de18 emacs`recursive_edit_1 at keyboard.c:720:9 [opt]
    frame #73: 0x000000010025e620 emacs`Frecursive_edit at keyboard.c:803:3 [opt]
    frame #74: 0x000000010025bb74 emacs`main(argc=<unavailable>, argv=<unavailable>) at emacs.c:2521:3 [opt]
    frame #75: 0x00000001a64b7f28 dyld`start + 2236

(lldb) command script import ~/emacs/29/etc/emacs_lldb.py
Emacs debugging support has been installed.
(lldb) xbacktrace
(unsigned char *) data = 0x000000010064bc60 "x-create-frame"
(unsigned char *) data = 0x00000001078da060 "x-create-frame-with-faces"
PVEC_COMPILED
(unsigned char *) data = 0x000000010062e7c0 "apply"
(unsigned char *) data = 0x00000001078da16d "frame-creation-function"
(unsigned char *) data = 0x00000001078da3ca "make-frame"
(unsigned char *) data = 0x00000001078ea70d "make-frame-on-display"
(unsigned char *) data = 0x0000000117c261b0 "frameset--restore-frame"
(unsigned char *) data = 0x000000010793e6bc "frameset-restore"
(unsigned char *) data = 0x0000000117c2ab10 "desktop-restore-frameset"
(unsigned char *) data = 0x0000000107859f5b "desktop-read"
(unsigned char *) data = 0x00000001006316e0 "eval"
(unsigned char *) data = 0x00000001078aefb9 "command-line-1"
(unsigned char *) data = 0x00000001078b0910 "command-line"
(unsigned char *) data = 0x00000001078b1860 "normal-top-level"