Subject: toolchain/29743: gcc optimisation hoses function pointer call
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <macallan18@earthlink.net>
List: netbsd-bugs
Date: 03/19/2005 18:38:00
>Number:         29743
>Category:       toolchain
>Synopsis:       gcc optimisation hoses function pointer call
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 19 18:38:00 +0000 2005
>Originator:     Michael Lorenz
>Release:        current
>Organization:
>Environment:
NetBSD Inishowen 3.99.1 NetBSD 3.99.1 (INISHOWEN) #321: Fri Mar 18 10:15:41 EST 2005  ml@Inishowen:/data/src/sys/arch/sparc64/compile/INISHOWEN sparc64

>Description:
I've found this when compiling XFree86 4.5 from xsrc:
When compiled with optimisations enabled this code in xsrc/xfree/xc/extras/freetype2/base/ftobjs.c:
     if ( service && service->name_index ) 
       result = service->name_index( face, glyph_name );
causes a SIGILL.
According to gdb it jumps into the structure pointed at by services, not the function pointer in service->name_index. This happens on both sparc64 and macppc but reportedly not on i386. 
A weird side-effect - when I add a printf() right before service->name_index( ) gets called  (and proper {} around it of course ) it doesn't coredump.

>How-To-Repeat:
The easiest way to trigger it is to run mkfontscale in xc/fonts/Type1
>Fix:
Workaround: compile with optimisation disabled.