Subject: Re: bug#4534: assertion failure at window.c:grow_mini_window

From: Juanma Barranquero <[email-masked]>
Date: Thu, 24 Sep 2009 14:58:07 +0200

On Thu, Sep 24, 2009 at 08:49, martin rudalics <[email-masked]> wrote:

>      if (EQ (Vresize_mini_windows, Qgrow_only))
>        ... fails so ...
>      else
>        ... gets executed ...
>        {
>          /* Always resize to exact size needed.  */
>          if (height > WINDOW_TOTAL_LINES (w))
>            ... fails again, so ...
>          else if (height < WINDOW_TOTAL_LINES (w))
>            ... we're here ...
>            {
>              int old_height = WINDOW_TOTAL_LINES (w);
>              freeze_window_starts (f, 0);
>              shrink_mini_window (w);
>              ... should resize the mini_window down to one line ...

That's exactly what happens, except that shrink_mini_window (w) does
*not* resize the miniwindow; it's still 6 lines height. So

>              if (height)
>                {
>                  freeze_window_starts (f, 1);
>                  ... and the following causes the assertion failure to
>                      trigger because the second arguments gets less
>                      than zero ...
>                  grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));

at this point, height == 5, WINDOW_TOTAL_LINES (w) == 6.

>                }
>
>              window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
>            }
>        }
>
> Now if I replace the check
>
>              if (height)
>
> by
>
>              if (height > WINDOW_TOTAL_LINES (w))
>
> I should be able to avoid the delta = -1 assertion failure in
> grow_mini_window.  Can you confirm my reasoning so far?

It's correct. Except that, as shrink_mini_window didn't shrink the
window, it remains at 6 lines.

> The fact that `height' is something like zero or less seems to stem from
> some miscalculation (probably caused by the line-wrapping part) earlier
> in the code of resize_mini_window.  If that's so could you try to find
> out why height is not at least one line?

I'm attaching the trace from inside shrink_mini_window. The call
happens just after I type '7'. At this moment, as said, the minibuffer
contains six lines of completion candidates, and the 7 reduces the
number of candidates so they fit in 5 lines.

If you need me to look into something specific that could help you
pinpoint the problem, just say so.

    Juanma

Breakpoint 3, shrink_mini_window (w=0x2fb1c00) at window.c:4680
4680      struct frame *f = XFRAME (w->frame);
(gdb) p *f
$1 = {
  size = 3053453312,
  next = 0x5b900313,
  name = 66312,
  icon_name = 65536,
  title = 0,
  focus_frame = 1588658176,
  root_window = -658373880,
  selected_window = -1241251100,
  minibuffer_window = 268698387,
  param_alist = 553976571,
  scroll_bars = 742,
  condemned_scroll_bars = 1588396032,
  menu_bar_items = -1940914176,
  face_alist = 357,
  menu_bar_vector = 279576576,
  buffer_predicate = 279576576,
  buffer_list = 0,
  buried_buffer_list = 1342177280,
  menu_bar_window = 525044,
  tool_bar_window = 524288,
  tool_bar_items = 4096,
  desired_tool_bar_string = 8519680,
  current_tool_bar_string = 1342193680,
  face_cache = 0x180308,
  menu_bar_items_used = 536870912,
  namebuf = 0xa2240010 <Address 0xa2240010 out of bounds>,
  current_pool = 0xa22402f5,
  desired_pool = 0xa22402f5,
  desired_matrix = 0xa22402f5,
  current_matrix = 0xa22402f5,
  glyphs_initialized_p = 1,
  resized_p = 0,
  force_flush_display_p = 1,
  default_face_done_p = 0,
  already_hscrolled_p = 1,
  updated_p = 1,
  minimize_tool_bar_window_p = 1,
  tool_bar_lines = -1574698251,
  n_tool_bar_rows = -1574698251,
  n_tool_bar_items = -1574698251,
  decode_mode_spec_buffer = 0xa22402f5 <Address 0xa22402f5 out of bounds>,
  insert_line_cost = 0xa22402f5,
  delete_line_cost = 0xa22402f5,
  insert_n_lines_cost = 0xa22402f5,
  delete_n_lines_cost = 0xa22402f5,
  text_lines = -1574698251,
  text_cols = -1574698251,
  total_lines = -1574698251,
  total_cols = -1574698251,
  new_text_lines = -1574698251,
  new_text_cols = -1574698251,
  left_pos = -1574698251,
  top_pos = -1574698251,
  pixel_height = -1574698251,
  pixel_width = -1574698251,
  resx = -3.2051845696591629e-144,
  resy = -3.2051845696591629e-144,
  x_pixels_diff = -1574698251,
  y_pixels_diff = -1574698251,
  win_gravity = -1574698251,
  size_hint_flags = -1574698251,
  border_width = -1574698251,
  internal_border_width = -1574698251,
  column_width = -1574698251,
  space_width = -1574698251,
  line_height = -1574698251,
  output_method = 2720269045,
  terminal = 0xa22402f5,
  output_data = {
    tty = 0xa22402f5,
    x = 0xa22402f5,
    w32 = 0xa22402f5,
    ns = 0xa22402f5,
    nothing = -1574698251
  },
  font_driver_list = 0xa22402f5,
  font_data_list = 0xa22402f5,
  fringe_cols = -1574698251,
  left_fringe_width = -1574698251,
  right_fringe_width = -1574698251,
  want_fullscreen = 2720269045,
  menu_bar_lines = -1574698251,
  external_menu_bar = 1,
  display_preempted = 0 '\0',
  visible = 1 '\001',
  iconified = 1 '\001',
  async_visible = 2 '\002',
  async_iconified = 36 '$',
  garbaged = -94 '\242',
  has_minibuffer = 1 '\001',
  wants_modeline = 0 '\0',
  can_have_scroll_bars = 2 '\002',
  auto_raise = 0 '\0',
  auto_lower = 0 '\0',
  no_split = 1 '\001',
  explicit_name = 0 '\0',
  window_sizes_changed = 0 '\0',
  mouse_moved = 1 '\001',
  pointer_invisible = 0 '\0',
  vertical_scroll_bar_type = 2720269045,
  desired_cursor = -1574698251,
  cursor_width = -1574698251,
  blink_off_cursor = -1574698251,
  blink_off_cursor_width = -1574698251,
  message_buf = 0xa22402f5 <Address 0xa22402f5 out of bounds>,
  scroll_bottom_vpos = -1574698251,
  config_scroll_bar_width = -1574698251,
  config_scroll_bar_cols = -1574698251,
  scroll_bar_actual_width = -1574698251,
  cost_calculation_baud_rate = -1574698251,
  alpha = {-3.2051845696591629e-144, -3.2051845696591629e-144},
  gamma = -3.2051845696591629e-144,
  extra_line_spacing = -1574698251,
  background_pixel = 2720269045,
  foreground_pixel = 2720269045
}
(gdb) n
4681      struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
(gdb) p *root
$2 = {
  size = 1073873018,
  vec_next = 0x3433200,
  frame = 55866552,
  mini_p = 365,
  next = 365,
  prev = 365,
  hchild = 365,
  vchild = 1668,
  parent = 77,
  left_col = 77,
  top_line = 0,
  total_lines = 17,
  total_cols = 28,
  buffer = 0,
  start = 74,
  pointm = 17,
  force_start = 55556516,
  optional_new_start = 50879400,
  hscroll = 20788139,
  min_hscroll = 51623432,
  use_time = 30,
  sequence_number = 30,
  temslot = 1,
  last_modified = 1,
  last_overlay_modified = 365,
  last_point = 365,
  last_had_star = 0,
  vertical_scroll_bar = 0,
  left_margin_cols = 0,
  right_margin_cols = 0,
  left_fringe_width = 0,
  right_fringe_width = 0,
  fringes_outside_margins = 0,
  scroll_bar_width = 0,
  vertical_scroll_bar_type = 0,
  last_mark_x = 0,
  last_mark_y = 16777216,
  window_end_pos = 48273409,
  window_end_vpos = 49329729,
  window_end_valid = 48273409,
  update_mode_line = 0,
  start_at_line_beg = 0,
  display_table = 0,
  dedicated = -1,
  base_line_number = 1,
  base_line_pos = 0,
  region_showing = 0,
  column_number_displayed = 0,
  redisplay_end_trigger = 48273456,
  resize_proportionally = 0,
  orig_total_lines = 0,
  orig_top_line = 321,
  window_parameters = 55653125,
  current_matrix = 0x347c2e3,
  desired_matrix = 0x2e09801,
  nrows_scale_factor = 49860659,
  ncols_scale_factor = 48273409,
  last_cursor = {
    x = 0,
    y = 48273409,
    hpos = 48273409,
    vpos = 50879186
  },
  cursor = {
    x = 54359045,
    y = 48273601,
    hpos = 48272499,
    vpos = 48628621
  },
  phys_cursor = {
    x = 48273409,
    y = 52445245,
    hpos = 49214980,
    vpos = 48300036
  },
  phys_cursor_type = 48303620,
  phys_cursor_width = 48273457,
  phys_cursor_ascent = 64,
  phys_cursor_height = 560,
  phys_cursor_on_p = 0,
  cursor_off_p = 0,
  last_cursor_off_p = 0,
  must_be_updated_p = 0,
  pseudo_window_p = 0,
  frozen_window_start_p = 0,
  vscroll = 48273409,
  window_end_bytepos = 48273409
}
(gdb) n
4683      if (save_restore_orig_size (root, CHECK_ORIG_SIZES))
(gdb) n
4685          save_restore_orig_size (root, RESTORE_ORIG_SIZES);
(gdb) p *root
$3 = {
  size = 1073745971,
  vec_next = 0x300f0c0,
  frame = 50008068,
  mini_p = 48273409,
  next = 50011140,
  prev = 48273409,
  hchild = 48273409,
  vchild = 50011652,
  parent = 48273409,
  left_col = 0,
  top_line = 24,
  total_lines = 264,
  total_cols = 680,
  buffer = 48273409,
  start = 48273409,
  pointm = 48273409,
  force_start = 48273409,
  optional_new_start = 48273409,
  hscroll = 0,
  min_hscroll = 0,
  use_time = 56,
  sequence_number = 48,
  temslot = 0,
  last_modified = 0,
  last_overlay_modified = 0,
  last_point = 1536,
  last_had_star = 48273409,
  vertical_scroll_bar = 54873988,
  left_margin_cols = 48273409,
  right_margin_cols = 48273409,
  left_fringe_width = 48273409,
  right_fringe_width = 48273409,
  fringes_outside_margins = 48273409,
  scroll_bar_width = 48273409,
  vertical_scroll_bar_type = 48273457,
  last_mark_x = 48273409,
  last_mark_y = 48273409,
  window_end_pos = 0,
  window_end_vpos = 0,
  window_end_valid = 48273409,
  update_mode_line = 48273409,
  start_at_line_beg = 48273457,
  display_table = 48273409,
  dedicated = 48273409,
  base_line_number = 8,
  base_line_pos = 8,
  region_showing = 48273409,
  column_number_displayed = 48273409,
  redisplay_end_trigger = 48273409,
  resize_proportionally = 48273409,
  orig_total_lines = 272,
  orig_top_line = 24,
  window_parameters = 48273409,
  current_matrix = 0x0,
  desired_matrix = 0x0,
  nrows_scale_factor = 1,
  ncols_scale_factor = 1,
  last_cursor = {
    x = 0,
    y = 0,
    hpos = 0,
    vpos = 0
  },
  cursor = {
    x = 0,
    y = 0,
    hpos = 0,
    vpos = 0
  },
  phys_cursor = {
    x = 0,
    y = 0,
    hpos = 0,
    vpos = 0
  },
  phys_cursor_type = -1,
  phys_cursor_width = -1,
  phys_cursor_ascent = 12,
  phys_cursor_height = 16,
  phys_cursor_on_p = 1,
  cursor_off_p = 0,
  last_cursor_off_p = 0,
  must_be_updated_p = 0,
  pseudo_window_p = 0,
  frozen_window_start_p = 0,
  vscroll = 0,
  window_end_bytepos = 0
}
(gdb) n
4686          adjust_glyphs (f);
(gdb) p *f
$4 = {
  size = 1073742869,
  next = 0x3245200,
  name = 49997459,
  icon_name = 48273409,
  title = 48273409,
  focus_frame = 48273409,
  root_window = 51028484,
  selected_window = 50011140,
  minibuffer_window = 50011140,
  param_alist = 52445997,
  scroll_bars = 54873092,
  condemned_scroll_bars = 48273409,
  menu_bar_items = 50027780,
  face_alist = 48839941,
  menu_bar_vector = 54169604,
  buffer_predicate = 48273409,
  buffer_list = 52389701,
  buried_buffer_list = 48273409,
  menu_bar_window = 48273409,
  tool_bar_window = 51028996,
  tool_bar_items = 55373828,
  desired_tool_bar_string = 49919939,
  current_tool_bar_string = 55037811,
  face_cache = 0x2fe9140,
  menu_bar_items_used = 0,
  namebuf = 0x2e32fa8 "emacs",
  current_pool = 0x0,
  desired_pool = 0x0,
  desired_matrix = 0x0,
  current_matrix = 0x0,
  glyphs_initialized_p = 1,
  resized_p = 0,
  force_flush_display_p = 0,
  default_face_done_p = 1,
  already_hscrolled_p = 0,
  updated_p = 1,
  minimize_tool_bar_window_p = 0,
  tool_bar_lines = 3,
  n_tool_bar_rows = 1,
  n_tool_bar_items = 14,
  decode_mode_spec_buffer = 0x30aa000 '-' <repeats 200 times>...,
  insert_line_cost = 0x0,
  delete_line_cost = 0x0,
  insert_n_lines_cost = 0x0,
  delete_n_lines_cost = 0x0,
  text_lines = 43,
  text_cols = 80,
  total_lines = 0,
  total_cols = 85,
  new_text_lines = 0,
  new_text_cols = 0,
  left_pos = 66,
  top_pos = 87,
  pixel_height = 688,
  pixel_width = 680,
  resx = 96,
  resy = 96,
  x_pixels_diff = 4,
  y_pixels_diff = 50,
  win_gravity = 1,
  size_hint_flags = 0,
  border_width = 2,
  internal_border_width = 0,
  column_width = 8,
  space_width = 8,
  line_height = 16,
  output_method = output_w32,
  terminal = 0x3263700,
  output_data = {
    tty = 0x2f97300,
    x = 0x2f97300,
    w32 = 0x2f97300,
    ns = 0x2f97300,
    nothing = 49902336
  },
  font_driver_list = 0x2fb7eb0,
  font_data_list = 0x0,
  fringe_cols = 2,
  left_fringe_width = 8,
  right_fringe_width = 8,
  want_fullscreen = FULLSCREEN_NONE,
  menu_bar_lines = 0,
  external_menu_bar = 1,
  display_preempted = 0 '\0',
  visible = 1 '\001',
  iconified = 0 '\0',
  async_visible = 1 '\001',
  async_iconified = 0 '\0',
  garbaged = 0 '\0',
  has_minibuffer = 1 '\001',
  wants_modeline = 1 '\001',
  can_have_scroll_bars = 1 '\001',
  auto_raise = 0 '\0',
  auto_lower = 0 '\0',
  no_split = 0 '\0',
  explicit_name = 0 '\0',
  window_sizes_changed = 0 '\0',
  mouse_moved = 0 '\0',
  pointer_invisible = 0 '\0',
  vertical_scroll_bar_type = vertical_scroll_bar_right,
  desired_cursor = FILLED_BOX_CURSOR,
  cursor_width = 48257509,
  blink_off_cursor = DEFAULT_CURSOR,
  blink_off_cursor_width = 0,
  message_buf = 0x313b000 "\200\002>\003P\034e\001",
  scroll_bottom_vpos = -1,
  config_scroll_bar_width = 17,
  config_scroll_bar_cols = 3,
  scroll_bar_actual_width = 24,
  cost_calculation_baud_rate = 19200,
  alpha = {-1, -1},
  gamma = 0,
  extra_line_spacing = 0,
  background_pixel = 50331647,
  foreground_pixel = 33554432
}
(gdb) n
4687          FRAME_WINDOW_SIZES_CHANGED (f) = 1;
(gdb) cont