Bug 29010

Summary: Compile time asserts triggered when checking sizes of truetype structs.
Product: cairo Reporter: M Joonas Pihlaja <jpihlaja>
Component: generalAssignee: Carl Worth <cworth>
Status: RESOLVED WORKSFORME QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: major    
Priority: medium CC: freedesktop
Version: 1.9.11   
Hardware: ARM   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Add packed attribute to TrueType font structs

Description M Joonas Pihlaja 2010-07-11 12:25:05 UTC
The compile time checks against the sizes of the tt_head_t, tt_name_t and tt_glyph_data_t structs fail when compiling cairo-truetype-subset.c on an ARM Debian Linux virtual machine image using gcc 4.3.2.  The image in question is from http://people.debian.org/~aurel32/qemu/arm/debian_lenny_arm_small.qcow2.
Also, the check for tt_name_t's size is duplicated.

 gcc -DHAVE_CONFIG_H -I. -I.. -I. -D_REENTRANT -I/home/user/build/prefix/include/pixman-1 -I/usr/include/libpng12 -Wall -Wextra -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Werror-implicit-function-declaration -Wnested-externs -Wpointer-arith -Wwrite-strings -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wpacked -Wswitch-enum -Wmissing-format-attribute -Wbad-function-cast -Wvolatile-register-var -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations -Wno-missing-field-initializers -Wno-unused-parameter -Wno-attributes -Wno-long-long -Winline -Wlogical-op -fno-strict-aliasing -fno-common -W,-D_FORTIFY_SOURCE=2 -O0 -MT cairo-truetype-subset.lo -MD -MP -MF .deps/cairo-truetype-subset.Tpo -c cairo-truetype-subset.c  -fPIC -DPIC -o .libs/cairo-truetype-subset.o
cairo-truetype-subset.c:103: error: size of array âcompile_time_assertion_at_line_103_failedâ is negative
cairo-truetype-subset.c:107: error: size of array âcompile_time_assertion_at_line_107_failedâ is negative
cairo-truetype-subset.c:108: error: size of array âcompile_time_assertion_at_line_108_failedâ is negative
cairo-truetype-subset.c:110: error: size of array âcompile_time_assertion_at_line_110_failedâ is negative
make[3]: *** [cairo-truetype-subset.lo] Error 1
airo-pthreads/src'
make[2]: *** [all] Error 2
airo-pthreads/src'
Comment 1 Behdad Esfahbod 2010-07-21 14:19:51 UTC
See:
https://bugzilla.gnome.org/show_bug.cgi?id=612402
Comment 2 Will Newton 2011-03-08 03:35:39 UTC
Created attachment 44224 [details] [review]
Add packed attribute to TrueType font structs
Comment 3 Bryce Harrington 2015-07-08 01:43:48 UTC
I notice the virtual machine image provided for reproducing the issue is no longer at the given link, so assume that means it is no longer relevant.  Since this bug triggered a compile-time assertion, I would assume we'd have heard more about this problem given how long ago this was reported, if it was reproducible on other ARM instances.  

Adding the packed attribute seems like a viable solution, but I'd want to test and make sure it's still required with a more modern compiler.  I'm going to tentatively close this as no longer reproducible but if anyone knows of or has a testable case, please reopen.

Meanwhile, the note about the duplicated tt_name_t is a good find.  I've pushed that change:
To ssh://git.cairographics.org/git/cairo
   943ba26..ad45e8f  master -> master

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.