Subject: bug#1450: w32_reset_fringes

From: Stephen Berman <[email-masked]>
Date: Tue, 02 Dec 2008 15:14:51 +0100

Sorry for the delayed response.

On Sun, 30 Nov 2008 10:19:33 +0100 martin rudalics <[email-masked]> wrote:

> Thanks for testing this.
>
>> I tried your patch after updating from the current CVS HEAD.  Now
>> starting with emacs -q --eval "(setq default-frame-alist
>> '((minibuffer)))" and trying to delete the minibuffer frame via the
>> window manager does not crash Emacs, but instead results in no deleted
>> frame and the error message "Attempt to delete a surrogate minibuffer
>> frame" (from handle-delete-frame).  Likewise, C-x 5 0 from the
>> minibuffer frame does not delete it, again showing the error message
>> (now from call-interactively).  With a non-minibuffer frame deletion via
>> either the window manager or C-x 5 0 succeeds; then as soon as I click
>> in the minibuffer frame, a new regular frame is created.
>
> I think that's the intended behavior.  At least it was until Emacs 22.
> And delete_frame depends on doing so as explained by this comment
>
> 	  /* We know that there must be some frame with a minibuffer out
> 	     there.  If this were not true, all of the frames present
> 	     would have to be minibufferless, which implies that at some
> 	     point their minibuffer frames must have been deleted, but
> 	     that is prohibited at the top; you can't delete surrogate
> 	     minibuffer frames.  */
>
>> As for starting with emacs -q and the evalling (delete-frame nil t),
>> this also does not make Emacs crash, but raises the error "Attempt to
>> delete the only frame".
>
> This is new behavior, obviously (it was there in the code, but commented
> out).
>
>> However, I apparently was mistaken in my post
>> cited above: I thought evalling (delete-frame nil t) produced a core
>> dump, like the attempt to delete the minibuffer frame did,
>
> Could you (or someone else on GNU/Linux) post a backtrace for the
> minibuffer deletion case?

Appended below.

>> but I cannot
>> reproduce that with the unpatched Emacs, so I must have been confused
>> about the source of the core file (which I since deleted).  Instead,
>> evalling (delete-frame nil t) in the unpatched Emacs simply kills Emacs,
>> verified under gdb ("Program exited normally.").  Sorry for misreporting
>> this yesterday.
>
> That's what Emacs 22 did in that case - exit normally.  But Emacs 22 did
> _not_ offer to save any unsaved buffers, so you might have lost some
> work.  Does it offer to save buffers on your Emacs 23?

No it does not.  So your fix is certainly needed.

Steve Berman

(gdb) r -Q --eval "(setq default-frame-alist '((minibuffer)))"
Starting program: /Users/steve/lib/emacs-cvs-gtk/src/emacs-23.0.60.17 -Q --eval "(setq default-frame-alist '((minibuffer)))"
[Thread debugging using libthread_db enabled]
[New Thread 0xb70dc6c0 (LWP 13023)]
[Switching to Thread 0xb70dc6c0 (LWP 13023)]

Breakpoint 1, abort () at /home/steve/cvsroot/emacs/src/emacs.c:428
428	  kill (getpid (), SIGABRT);
(gdb) bt full
#0  abort () at /home/steve/cvsroot/emacs/src/emacs.c:428
No locals.
#1  0x08089931 in redisplay_internal (preserve_echo_area=<value optimized out>)
    at /home/steve/cvsroot/emacs/src/xdisp.c:11393
	w = (struct window *) 0x0
	pause = 0
	must_finish = 0
	number_of_visible_frames = 0
	polling_stopped_here = 0
	old_frame = 141412100
	consider_all_windows_p = 0
#2  0x0812fc6e in read_char (commandflag=1, nmaps=2, maps=0xbf852ac0, 
    prev_event=137943241, used_mouse_menu=0xbf852b74, end_time=0x0)
    at /home/steve/cvsroot/emacs/src/keyboard.c:2649
	c = <value optimized out>
	local_getcjmp = {{
    __jmpbuf = {2, 143631964, 1, -1081791880, -1774884314, -1180720311}, 
    __mask_was_saved = 0, 
    __saved_mask = {
      __val = {0, 0, 40, 3213175168, 1, 0, 4294967295, 3213175228, 138076240, 
        3213175432, 135828553, 137972617, 8, 138076244, 1228226696, 136140190, 
        0, 1, 1, 135545443, 138158953, 1, 3213175000, 1, 143548420, 137969100, 
        3213175000, 8192, 0, 0, 0, 0}
    }
  }}
	save_jump = {{
    __jmpbuf = {0, 0, 0, 0, 0, 0}, 
    __mask_was_saved = 0, 
    __saved_mask = {
      __val = {0 <repeats 32 times>}
    }
  }}
	key_already_recorded = 0
	tem = 138232705
	save = <value optimized out>
	previous_echo_area_message = 137943241
	also_record = 137943241
	reread = 0
	polling_stopped_here = <value optimized out>
	orig_kboard = (struct kboard *) 0x872cb00
#3  0x08131fd1 in read_key_sequence (keybuf=0xbf852c24, bufsize=30, 
    prompt=137943241, dont_downcase_last=0, can_return_switch_frame=1, 
    fix_current_buffer=1) at /home/steve/cvsroot/emacs/src/keyboard.c:9344
	interrupted_kboard = (KBOARD *) 0x872cb00
	key = 0
	used_mouse_menu = 0
	echo_local_start = 0
	last_real_key_start = 0
	keys_local_start = 0
	local_first_binding = 1
	from_string = 137943241
	count = 2
	t = 0
	echo_start = 0
	keys_start = 0
	nmaps = 2
	nmaps_allocated = 2
	defs = (Lisp_Object * volatile) 0xbf852aa0
	submaps = (Lisp_Object * volatile) 0xbf852ac0
	orig_local_map = 137943241
	orig_keymap = 137943241
	localized_local_map = 0
	first_binding = 1
	first_unbound = 31
	mock_input = 0
	fkey = {
  parent = 138343165, 
  map = 138343165, 
  start = 0, 
  end = 0
}
	keytran = {
  parent = 137936765, 
  map = 137936765, 
  start = 0, 
  end = 0
}
	indec = {
  parent = 138343181, 
  map = 138343181, 
  start = 0, 
  end = 0
}
	shift_translated = 0
	delayed_switch_frame = 137943241
	original_uppercase = 2
	original_uppercase_position = -1
	starting_buffer = (struct buffer *) 0x83ae050
	fake_prefixed_keys = 137943241
#4  0x081340f4 in command_loop_1 ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:1621
	cmd = <value optimized out>
	lose = <value optimized out>
	nonundocount = 0
	keybuf = {140896125, 1, -1219133440, 0, 0, 0, -1208666280, 
  -1472036457, 1011, 88216588, 55, -1220440836, -1220445908, 0, 0, 0, 1, 1010, 
  -1223340480, 0, -1081791352, -1081791504, 0, 0, 137943241, 138407017, 0, 
  138468728, 138468712, -1081791320}
	i = <value optimized out>
	prev_modiff = 4
	prev_buffer = (struct buffer *) 0x8393dc8
	already_adjusted = 0
#5  0x0818ed60 in internal_condition_case (bfun=0x8133f10 <command_loop_1>, 
    handlers=137986481, hfun=0x812e7a0 <cmd_error>)
    at /home/steve/cvsroot/emacs/src/eval.c:1511
	val = <value optimized out>
	c = {
  tag = 137943241, 
  val = 137943241, 
  next = 0xbf852dd0, 
  gcpro = 0x0, 
  jmp = {{
      __jmpbuf = {0, 138468728, 138468712, -1081791080, -1774417370, 
        -1379948215}, 
      __mask_was_saved = 0, 
      __saved_mask = {
        __val = {3213176208, 3086313080, 134543677, 141164546, 0, 0, 
          3077189516, 3086311412, 3213175804, 3071626684, 3213175856, 
          3086236055, 3075821888, 141190592, 141190592, 3075817460, 
          3075833856, 3213176432, 3213176140, 3213176432, 3213176280, 
          135516324, 2, 3213176292, 3074542620, 3075833856, 0, 4294967295, 
          3086311412, 3086313080, 134523392, 3213176224}
      }
    }}, 
  backlist = 0x0, 
  handlerlist = 0x0, 
  lisp_eval_depth = 0, 
  pdlcount = 2, 
  poll_suppress_count = 1, 
  interrupt_input_blocked = 0, 
  byte_stack = 0x0
}
	h = {
  handler = 137986481, 
  var = 137943241, 
  chosen_clause = 1, 
  tag = 0xbf852cbc, 
  next = 0x0
}
#6  0x0812dcf5 in command_loop_2 ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:1338
	val = 0
#7  0x0818ee3a in internal_catch (tag=137982457, 
    func=0x812dcd0 <command_loop_2>, arg=137943241)
    at /home/steve/cvsroot/emacs/src/eval.c:1247
	c = {
  tag = 137982457, 
  val = 137943241, 
  next = 0x0, 
  gcpro = 0x0, 
  jmp = {{
      __jmpbuf = {0, 138468728, 138468712, -1081790824, -1774294490, 
        -1380339383}, 
      __mask_was_saved = 0, 
      __saved_mask = {
        __val = {0, 0, 0, 0, 0, 0, 3074961710, 0, 0, 0, 0, 0, 0, 0, 
          3075822032, 192, 0, 3075821944, 177, 22, 138182968, 138180274, 
          137969096, 3213176456, 135791115, 138182969, 138180274, 137943241, 
          137969096, 137943265, 138180272, 0}
      }
    }}, 
  backlist = 0x0, 
  handlerlist = 0x0, 
  lisp_eval_depth = 0, 
  pdlcount = 2, 
  poll_suppress_count = 1, 
  interrupt_input_blocked = 0, 
  byte_stack = 0x0
}
#8  0x0812e5ff in command_loop ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:1317
No locals.
#9  0x0812e97b in recursive_edit_1 ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:942
	val = <value optimized out>
#10 0x0812eac4 in Frecursive_edit ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:1004
	buffer = 137943241
#11 0x081231b7 in main (argc=4, argv=0xbf8532a4)
    at /home/steve/cvsroot/emacs/src/emacs.c:1777
	dummy = -1081789960
	stack_bottom_variable = 8 '\b'
	do_initial_setlocale = 1
	skip_args = 0
	rlim = {
  rlim_cur = 8388608, 
  rlim_max = 18446744073709551615
}
	no_loadup = 0
	junk = 0x0
	dname_arg = 0x0
(gdb)