Subject: bug#527: input-input-method / Many crashes / Japanese input

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Fri, 04 Jul 2008 12:29:46 +0900

>>>>> On Thu, 3 Jul 2008 11:45:07 +0100, David Reitter <[email-masked]> said:

> Begin forwarded message:

>> From: "Jose Figueroa-O'Farrill" <[email-masked]>
>> Date: 3 July 2008 10:52:27 BST
>> To: [email-masked]
>> Subject: [Aquamacs-bugs] Many crashes in 1.4
>> Reply-To: [email-masked]
>> 
>> 
>> Hi,
>> 
>> It's the third time that Aquamacs 1.4 crashes while typing.  This
>> had not happened in a looooong time.  This time I managed to save the
>> crash report which I include below.  I'm afraid that I don't know how
>> to reproduce it.
>> 
>> Cheers, José
>> 
>> 
>> Date/Time:      2008-07-02 23:06:09.682 +0200
>> OS Version:     10.4.11 (Build 8S165)
>> Report Version: 4
>> 
>> Command: Aquamacs Emacs
>> Path:    /Applications/Aquamacs Emacs.app/Contents/MacOS/Aquamacs  
>> Emacs
>> Parent:  WindowServer [62]
>> 
>> Version: Aquamacs 1.4, GNU Emacs 22 ()
>> 
>> PID:    14598
>> Thread: 0
>> 
>> Exception:  EXC_BAD_ACCESS (0x0001)
>> Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000008
>> 
>> Thread 0 Crashed:
>> 0   org.gnu.AquamacsEmacs          	0x00175138  
>> mac_handle_text_input_event + 1720
(snip)
>> Thread 0 crashed with PPC Thread State 64:
>> r4: 0x0000000000000000   r5: 0x00000000081f0800   r6:  
>> 0x0000000000000000   r7: 0x0000000000000059

If your object file is not much different from mine, the crash seems
to happen just before a call to Long2Fix.

_mac_handle_text_input_event:

 +1708  00000a6c  81230008  lwz      r9,0x8(r3)
 +1712  00000a70  5402103a  rlwinm   r2,r0,2,0,29
 +1716  00000a74  7cc2482e  lwzx     r6,r2,r9
 +1720  00000a78  83a60008  lwz      r29,0x8(r6)
 +1724  00000a7c  2f9d0000  cmpwi    cr7,r29,0x0
 +1728  00000a80  419efe88  beq      cr7,0x908
 +1732  00000a84  807d0008  lwz      r3,0x8(r29)
 +1736  00000a88  48008959  bl       0x93e0           _Long2Fix

Could you try the patch below?

				     YAMAMOTO Mitsuharu
				[email-masked]

Index: src/mactoolbox.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/mactoolbox.c,v
retrieving revision 1.1.2.4
diff -c -p -r1.1.2.4 mactoolbox.c
*** src/mactoolbox.c	23 Apr 2008 08:56:20 -0000	1.1.2.4
--- src/mactoolbox.c	4 Jul 2008 03:20:27 -0000
*************** mac_handle_text_input_event (next_handle
*** 575,581 ****
  	    int hpos, vpos, x, y;
  	    struct glyph_row *row;
  	    struct glyph *glyph;
! 	    XFontStruct *font;
  
  	    f = mac_focus_frame (&one_mac_display_info);
  	    w = XWINDOW (f->selected_window);
--- 575,581 ----
  	    int hpos, vpos, x, y;
  	    struct glyph_row *row;
  	    struct glyph *glyph;
! 	    struct face *face;
  
  	    f = mac_focus_frame (&one_mac_display_info);
  	    w = XWINDOW (f->selected_window);
*************** mac_handle_text_input_event (next_handle
*** 600,608 ****
  		   + row->visible_height
  		   + f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
  
! 	    font = FACE_FROM_ID (f, glyph->face_id)->font;
! 	    if (font)
  	      {
  		Fixed point_size = Long2Fix (font->mac_fontsize);
  		short height = row->visible_height;
  		short ascent = row->ascent;
--- 600,609 ----
  		   + row->visible_height
  		   + f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
  
! 	    face = FACE_FROM_ID (f, glyph->face_id);
! 	    if (face && face->font)
  	      {
+ 		XFontStruct *font = face->font;
  		Fixed point_size = Long2Fix (font->mac_fontsize);
  		short height = row->visible_height;
  		short ascent = row->ascent;