[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
odd fonts/t1lib compile mystery on osx
I'm on a quest to get math/grace working on osx. Thomas solved a
x11/motif problem blocking me by updating the package from 2.3.4
to 2.3.8 (thanks wiz!). So motif programs now work on osx, but grace
is still crashing...
I've isolated the issue causing this grace crash to fonts/t1lib
and I now have a standalone test program outside of grace that triggers
So I started looking at fonts/t1lib with lldb and discovered the
- test crashes with standard fonts/t1lib compiled "-O2 -g"
- test runs fine with fonts/t1lib compiled with just "-g"
- test runs fine with fonts/t1lib compiled with "-O2 -g -fno-builtin"
- test runs fine with fonts/t1lib compiled with "-O2 -g" EXCEPT
for the file lib/type1/objects.c which I compile without "-O2"
- test runs fine with fonts/t1lib compiled with "-O2 -g"
provided I move the source code for the function abort(string,no)
from the file lib/type1/objects.c to some other source code
file (e.g. lib/type1/util.c is the one I tried)
The abort(string,no) function (which lives in lib/type1/objects.c)
normally looks like:
void abort(string, no)
extern jmp_buf stck_state;
LineIOTrace = TRUE;
longjmp( stck_state, no);
If I replace the entire body of that function with just this one line:
then the test runs fine (and does not print 'ABORT!').
On the other hand, it will crash if I replace it with this:
#include <err.h> /* at top of file */
but it works ok if I don't include <err.h> and manually generate
the prototype for errx() like this:
extern errx(int, const char *, ...);
I think it has something to do with the clang optimizer and functions
that are declared with __dead2 in /usr/include prototypes... where
__dead2 is defined in osx cdefs.h as:
#define __dead2 __attribute__((noreturn))
if that abort(string,no) ends in a function that is declared __dead2
(e.g. longjmp, exit, errx) then the program crashes. Otherwise it
is ok. When I manually defined the errx() protoype I didn't include
the __dead2, so the program did not crash.
I think the optimizer inlines that abort(string,no) function in
the file it is declared lib/type1/objects.c in the 8 places where
it is called. When I moved abort(string,no) source code to
lib/type1/util.c (a file that does not call abort(string,no)) this
inline goes away and the crash goes away too.
I don't know if fonts/libt1 is doing something bad that is confusing
Apple's clang, or if it is a bug. Anyone have any insight on this?
I can send the test program setup if anyone want to replicate.
In the meantime, I think I can solve this at the pkgsrc level
by adding a patch to move that abort() function source code
from objects.c to util.c. hopefully that's ok?
Main Index |
Thread Index |