I built the emacs packages myself with debugging information. The crash
happens at fringe.c:1214

(gdb) r
Program received signal SIGFPE, Arithmetic exception.
0x08126361 in compute_fringe_widths (f=0x85d8d00, redraw=1) at fringe.c:1214
(gdb) bt
#0  0x08126361 in compute_fringe_widths (f=0x85d8d00, redraw=1) at fringe.c:1214
#1  0x081094ed in x_new_font (f=0x85d8d00, font_object=141700660, fontset=2) at 
xterm.c:8372
#2  0x08064ce9 in x_set_font (f=0x85d8d00, arg=141729051, oldval=138348745) at 
frame.c:3445
#3  0x08063a3b in x_set_frame_parameters (f=0x85d8d00, alist=138348745) at 
frame.c:3017
#4  0x080662b3 in x_default_parameter (f=0x85d8d00, alist=139436189, 
prop=138561249, deflt=141700660, xprop=0x825029a "font", xclass=0x8250295 
"Font", type=RES_TYPE_STRING) at frame.c:4130
#5  0x08113b6b in x_default_font_parameter (f=0x85d8d00, parms=139436189) at 
xfns.c:3043
#6  0x0811444c in Fx_create_frame (parms=139436189) at xfns.c:3257
#7  0x081cc469 in Ffuncall (nargs=2, args=0xbfffe510) at eval.c:3045
#8  0x08209371 in Fbyte_code (bytestr=136975739, vector=136975756, maxdepth=40) 
at bytecode.c:678
(..)
The code there is

(gdb) l
1209        {
1210          int left_wid = left_fringe_width >= 0 ? left_fringe_width : 
-left_fringe_width;
1211          int right_wid = right_fringe_width >= 0 ? right_fringe_width : 
-right_fringe_width;
1212          int conf_wid = left_wid + right_wid;
1213          int font_wid = FRAME_COLUMN_WIDTH (f);
1214          int cols = (left_wid + right_wid + font_wid-1) / font_wid;
1215          int real_wid = cols * font_wid;
1216          if (left_wid && right_wid)
1217            {
1218              if (left_fringe_width < 0)

A division by zero occurs because font_wid is 0.

(gdb) p font_wid
$3 = 0
(gdb) p left_wid
$4 = 8
(gdb) p right_wid
$5 = 8

font_wid is calculated using FRAME_COLUMN_WIDTH, which is defined in frame.h, 
868:
#define FRAME_COLUMN_WIDTH(F) ((F)->column_width)

(gdb) p *f
$1 = {size = 1073742869, next = 0x85be378, name = 141729355, icon_name = 
138348745, title = 138348745, focus_frame = 138348745, root_window = 140609412, 
selected_window = 140609412, minibuffer_window = 140104924, param_alist = 
139429197, scroll_bars = 138348745, condemned_scroll_bars = 138348745, 
menu_bar_items = 138348745, face_alist = 138348745, menu_bar_vector = 
138348745, buffer_predicate = 138348745, buffer_list = 139434141, 
buried_buffer_list = 138348745, menu_bar_window = 138348745, tool_bar_window = 
138348745, tool_bar_items = 138348745, desired_tool_bar_string = 138348745, 
current_tool_bar_string = 138348745, face_cache = 0x0, menu_bar_items_used = 0, 
namebuf = 0x0, current_pool = 0x0, desired_pool = 0x0, desired_matrix = 0x0, 
current_matrix = 0x0, glyphs_initialized_p = 0, resized_p = 0, 
force_flush_display_p = 0, default_face_done_p = 0, already_hscrolled_p = 0, 
updated_p = 0, minimize_tool_bar_window_p = 0, tool_bar_lines = 0, 
n_tool_bar_rows = 0, n_tool_bar_items = 0, decode_mode_spec_buffer = 0x0, 
insert_line_cost = 0x0, delete_line_cost = 0x0, insert_n_lines_cost = 0x0, 
delete_n_lines_cost = 0x0, text_lines = 10, text_cols = 10, total_lines = 0, 
total_cols = 10, new_text_lines = 0, new_text_cols = 0, left_pos = 0, top_pos = 
0, pixel_height = 0, pixel_width = 0, resx = 0, resy = 0, x_pixels_diff = 0, 
y_pixels_diff = 0, win_gravity = 0, size_hint_flags = 0, border_width = 0, 
internal_border_width = 0, column_width = 0, space_width = 0, line_height = 0, 
output_method = output_x_window, terminal = 0x85f08c0, output_data = {tty = 
0x8602a90, x = 0x8602a90, w32 = 0x8602a90, ns = 0x8602a90, nothing = 
140520080}, font_driver_list = 0x86684b8, font_data_list = 0x0, fringe_cols = 
0, left_fringe_width = 0, right_fringe_width = 0, want_fullscreen = 
FULLSCREEN_NONE, menu_bar_lines = 0, external_menu_bar = 0, display_preempted = 
0 '\000', visible = 0 '\000', iconified = 0 '\000', async_visible = 0 '\000', 
async_iconified = 0 '\000', garbaged = 1 '\001', has_minibuffer = 1 '\001', 
wants_modeline = 1 '\001', can_have_scroll_bars = 1 '\001', auto_raise = 0 
'\000', auto_lower = 0 '\000', no_split = 0 '\000', explicit_name = 0 '\000', 
window_sizes_changed = 0 '\000', mouse_moved = 0 '\000', 
vertical_scroll_bar_type = vertical_scroll_bar_none, desired_cursor = 
FILLED_BOX_CURSOR, cursor_width = 0, blink_off_cursor = FILLED_BOX_CURSOR, 
blink_off_cursor_width = 0, message_buf = 0x0, scroll_bottom_vpos = 0, 
config_scroll_bar_width = 0, config_scroll_bar_cols = 0, 
scroll_bar_actual_width = 0, cost_calculation_baud_rate = 0, alpha = {0, 0}, 
gamma = 0, extra_line_spacing = 0, background_pixel = 0, foreground_pixel = 0}


If I start the debugger from a KDE session there are different values:

Breakpoint 1, compute_fringe_widths (f=0x8580f90, redraw=1) at fringe.c:1214
(gdb) p font_wid
$1 = 10
(gdb) p left_wid
$2 = 8
(gdb) p right_wid
$3 = 8

Interesting differences in the frame struct are:
LXDE: resx = 0, resy = 0, column_width = 0, space_width = 0, line_height = 0
KDE : resx = 93.068702290076331, resy = 94.953271028037378, column_width = 10, 
space_width = 10, line_height = 20

The patch which might cause this bug is http://bazaar.launchpad.net
/~ubuntu-branches/ubuntu/lucid/emacs23/lucid-proposed/revision/13, and
there is a debian/patches/fix-huge-fonts.diff which modifies these frame
fields:

172 +static void
173 +apply_xft_settings (dpyinfo, send_event_p)
174 + struct x_display_info *dpyinfo;
175 + int send_event_p;
176 +{
177 + double dpi;
178 + if (!read_xft_dpi (dpyinfo, &dpi))
179 +   return;
180 +
181 + /* Change the DPI on this display and all frames on the display. */
182 + Lisp_Object frame, tail;
183 + dpyinfo->resy = dpyinfo->resx = dpi;
184 + FOR_EACH_FRAME (tail, frame)
185 +   if (FRAME_X_P (XFRAME (frame))
186 +       && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
187 +     XFRAME (frame)->resy = XFRAME (frame)->resx = dpi;
188 +}

It seems that on LXDE, a dpi value of 0 is returned, which is then set
to the frame's resy and resx properties and later propagates to
column_width. If I catch this case, emacs runs again:

--- debian/patches/fix-huge-fonts.diff.orig     2011-02-25 09:27:38.900821363 
+0100
+++ debian/patches/fix-huge-fonts.diff  2011-02-25 08:00:53.469874683 +0100
@@ -16,7 +16,7 @@
  #ifdef USE_LUCID
  extern int xlwmenu_window_p P_ ((Widget w, Window window));
  extern void xlwmenu_redisplay P_ ((Widget));
-@@ -5829,6 +5832,237 @@ event_handler_gdk (gxev, ev, data)
+@@ -5829,6 +5832,239 @@ event_handler_gdk (gxev, ev, data)
  }
  #endif /* USE_GTK */
  
@@ -177,6 +177,8 @@
 + double dpi;
 + if (!read_xft_dpi (dpyinfo, &dpi))
 +   return;
++ if (dpi == 0.0)
++   return;
 +
 + /* Change the DPI on this display and all frames on the display. */
 + Lisp_Object frame, tail;

Regards,
Urs

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/684613

Title:
  emacs crashes with "Arithmetic error"

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to