Hey. I have a very simple text output to buffer system which will crash randomly. It will be fine for DAYS, then sometimes it'll crash a few times in a few minutes. The callstack is almost exactly the same for other guys who use higher level controls:
http://discussions.apple.com/thread.jspa?messageID=7949746
http://stackoverflow.com/questions/1978997/iphone-app-crashed-assertion-failed-function-evictglyphentryfromstrike-file
It crashes at the line (below as well in drawTextToBuffer()):
[nsString drawAtPoint:CGPointMake(0, 0) withFont:clFont];
I have the same call of "evict_glyph_entry_from_cache" with the abort calls immediately following it.
Apparently it happens to other people. I can say that my NSString* is perfectly fine at the time of the crash. I can read the text from the debugger just fine.
static CGColorSpaceRef curColorSpace;
static CGContextRef myContext;
static float w, h;
static int iFontSize;
static NSString* sFontName;
static UIFont* clFont;
static int iLineHeight;
unsigned long* txb; /* 256x256x4 Buffer */
void selectFont(int iSize, NSString* sFont)
{
iFontSize = iSize;
clFont = [UIFont fontWithName:sFont size:iFontSize];
iLineHeight = (int)(ceil([clFont capHeight]));
}
void initText()
{
w = 256;
h = 256;
txb = (unsigned long*)malloc_(w * h * 4);
curColorSpace = CGColorSpaceCreateDeviceRGB();
myContext = CGBitmapContextCreate(txb, w, h, 8, w * 4, curColorSpace, kCGImageAlphaPremultipliedLast);
selectFont(12, @"Helvetica");
}
void drawTextToBuffer(NSString* nsString)
{
CGContextSaveGState(myContext);
CGContextSetRGBFillColor(myContext, 1, 1, 1, 1);
UIGraphicsPushContext(myContext);
/* This line will crash. It crashes even with constant Strings.. At the time of the crash, the pointer to nsString is perfectly fine. The data looks fine! */
[nsString drawAtPoint:CGPointMake(0, 0) withFont:clFont];
UIGraphicsPopContext();
CGContextRestoreGState(myContext);
}
It will happen with other non-unicode supporting methods as well such as CGContextShowTextAtPoint(); the callstack is similar with that as well.
Is this any kind of known issue with the iPhone? Or, perhaps, can something outside of this cause be causing an exception in this particular call (drawAtPoint)?