Subject: bug#11541: 24.0.97; Crash when visiting file on OS X 10.7.3

From: Eli Zaretskii <[email-masked]>
Date: Thu, 31 May 2012 20:54:49 +0300

> From: "C. Florian Ebeling" <[email-masked]>
> Date: Thu, 31 May 2012 19:27:13 +0200
> Cc: Chong Yidong <[email-masked]>,
>  [email-masked]
> 
> > This might be a slower way to find the culprit, but I think it is a
> > lot more sure to give good results.
> 
> This is what a healthy and the crashing call produce with font_spec and fdesc being printed:
> 
> Breakpoint 2, ns_findfonts (font_spec=4338015181, isMatch=0 '\000') at nsfont.m:496
> 496	    Lisp_Object tem, list = Qnil;
> #<font-spec ns nil Monaco nil iso10646-1 nil nil nil nil nil nil nil ((:script . symbol))>
> 
> Breakpoint 3, ns_findfonts (font_spec=4338015181, isMatch=0 '\000') at nsfont.m:529
> 529	    if (!FONT_SPEC_P (font_spec))
> #<font-spec ns nil Monaco nil iso10646-1 nil nil nil nil nil nil nil ((:script . symbol))>
> 
> Breakpoint 2, ns_findfonts (font_spec=4338015181, isMatch=0 '\000') at nsfont.m:496
> 496	    Lisp_Object tem, list = Qnil;
> #<font-spec ns apple nil nil iso10646-1 nil nil nil nil nil nil nil ((:script . symbol))>
> 
> Breakpoint 3, ns_findfonts (font_spec=4338015181, isMatch=0 '\000') at nsfont.m:529
> 529	    if (!FONT_SPEC_P (font_spec))
> #<font-spec ns apple nil nil iso10646-1 nil nil nil nil nil nil nil ((:script . symbol))>
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
> 0x00007fff8966d3c2 in CFStringGetLength ()
> 
> (gdb) i b
> Num Type           Disp Enb Address            What
> --- snip ---
> 2   breakpoint     keep y   0x00000001001a0fb5 in ns_findfonts at nsfont.m:496
> 	breakpoint already hit 7 times
>         pp font_spec
>         continue
> 3   breakpoint     keep y   0x00000001001a11ca in ns_findfonts at nsfont.m:529
> 	breakpoint already hit 7 times
>         pp font_spec
>         continue
> 
> I can't really tell which font_spec is acceptable, and which not, though.
> 
> The crashing one has a third element of nil, is that ok or not?

I have no idea.  Assuming I understand the data you presented, one
font (Monaco) is OK, but another (apple) is not?  That still makes no
sense to me.

That's why I suggested to actually _step_ through the code of
ns_findfonts, one line at a time, including stepping into any
functions it calls whose source is part of Emacs, looking for possible
culprits, like NULL pointers, garbled pointers, uninitialized
variables, blown-up stack, etc.  Just showing a few breakpoint hits
won't cut it, as it didn't until now, if my experience in debugging
tricky problems means anything.

Like I said: it might be slower, but in the end it will surely
deliver.

TIA