Occasional glyph crash

Hey,
I very rarely get a crash with the following stack trace. I know this is not much information, but maybe somebody has an idea? The problem seems to be a textlayouts draw function. But this is very hard to debug since it happens very rarely and the trace is so strange with the glyph stuff. We are using a font that is included in the binary data. Could there be a problem with that? No matter what I do, I can’t reproduce it.

0   Nylon                               0x0000000126b632b1 _ZN4juceL11handleCrashEi + 65
1   libsystem_platform.dylib            0x00007fff67b4ab3d _sigtramp + 29
2   ???                                 0x0000000000000000 0x0 + 0
3   libFontParser.dylib                 0x00007fff38bef27b _ZNK17TSFNTOpenTypeFont10GetCFFDataEim + 53
4   libFontParser.dylib                 0x00007fff38be39f8 _ZNK13TOpenTypeFont13GetCharStringEt + 90
5   libFontParser.dylib                 0x00007fff38bdadd8 _ZNK17TType1FontHandler12ParseOutlineEtR22TType1RenderingContext + 52
6   libFontParser.dylib                 0x00007fff38bdad8e _ZNK32TType1FontType2CharStringHandler12ParseOutlineEtR22TType1RenderingContext + 14
7   libFontParser.dylib                 0x00007fff38c2ae9f _ZNK32TType1FontType2CharStringHandler14GetOutlinePathEtRK18TGlyphOutlineBatchPb + 269
8   libFontParser.dylib                 0x00007fff38bc4d93 FPFontCopyGlyphPath + 371
9   CoreGraphics                        0x00007fff3ab75bd3 CGFontCreateGlyphPath + 42
10  CoreGraphics                        0x00007fff3ab75991 CGFontCreateGlyphBitmapWithDilation + 787
11  CoreGraphics                        0x00007fff3ab75395 _ZN14CGGlyphBuilder22create_missing_bitmapsEPK17CGGlyphIdentifiermPPK13CGGlyphBitmap + 169
12  CoreGraphics                        0x00007fff3ab74f39 _ZN14CGGlyphBuilder18lock_glyph_bitmapsEPK17CGGlyphIdentifiermPPK13CGGlyphBitmap + 165
13  CoreGraphics                        0x00007fff3ab74d5a render_glyphs + 184
14  CoreGraphics                        0x00007fff3ab74560 draw_glyph_bitmaps + 1071
15  CoreGraphics                        0x00007fff3ab740a3 ripc_DrawGlyphs + 1454
16  CoreGraphics                        0x00007fff3ab73757 CGContextDelegateDrawGlyphs + 906
17  AppKit                              0x00007fff37f91090 __backing_store_DrawGlyphs_block_invoke + 48
18  AppKit                              0x00007fff37e6d548 backing_store_delegate + 875
19  AppKit                              0x00007fff38192789 backing_store_DrawGlyphs.llvm.6249430987493125948 + 1500
20  CoreGraphics                        0x00007fff3ab73757 CGContextDelegateDrawGlyphs + 906
21  CoreGraphics                        0x00007fff3aed746b draw_glyphs + 712
22  CoreGraphics                        0x00007fff3aed713d CGContextShowGlyphs + 494
23  Nylon                               0x0000000126bb196c _ZN4juce19CoreGraphicsContext9drawGlyphEiRKNS_15AffineTransformE + 492
24  Nylon                               0x0000000126bdf74d _ZNK4juce10TextLayout4drawERNS_8GraphicsENS_9RectangleIfEE + 637
25  Nylon                               0x0000000126c373e9 _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 137
26  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
27  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
28  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
29  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
30  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
31  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
32  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
33  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
34  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
35  Nylon                               0x0000000126c3779d _ZN4juce9Component25paintComponentAndChildrenERNS_8GraphicsE + 1085
36  Nylon                               0x0000000126c60506 _ZN4juce13ComponentPeer11handlePaintERNS_23LowLevelGraphicsContextE + 310
37  Nylon                               0x0000000126c59d10 _ZN4juce15JuceNSViewClass8drawRectEP11objc_objectP13objc_selector6CGRect + 480
38  AppKit                              0x00007fff37d8ac29 _NSViewDrawRect + 66
39  AppKit                              0x00007fff37d75a22 -[NSView _drawRect:clip:] + 1745
40  AppKit                              0x00007fff37d738e6 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 4808
41  AppKit                              0x00007fff37d73226 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3080
42  AppKit                              0x00007fff37d73226 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3080
43  AppKit                              0x00007fff37d725f8 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 65
44  AppKit                              0x00007fff37d6ff2a -[NSView _oldDisplayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 1887
45  AppKit                              0x00007fff37d6f569 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 253
46  AppKit                              0x00007fff37d6c152 -[NSView displayIfNeeded] + 1300
47  AppKit                              0x00007fff37d68ee8 -[NSWindow displayIfNeeded] + 283
48  AppKit                              0x00007fff37d68d27 __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 722
49  AppKit                              0x00007fff37d63e2a NSDisplayCycleObserverInvoke + 170
50  AppKit                              0x00007fff37d6399f NSDisplayCycleFlush + 1073
51  QuartzCore                          0x00007fff456c425b _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 49
52  QuartzCore                          0x00007fff456c3c22 _ZN2CA11Transaction6commitEv + 186
53  AppKit                              0x00007fff37d63305 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke + 274
54  CoreFoundation                      0x00007fff3a76c8ed __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
55  CoreFoundation                      0x00007fff3a76c822 __CFRunLoopDoObservers + 452
56  CoreFoundation                      0x00007fff3a70e345 __CFRunLoopRun + 1166
57  CoreFoundation                      0x00007fff3a70dc64 CFRunLoopRunSpecific + 463
58  HIToolbox                           0x00007fff399a4ab5 RunCurrentEventLoopInMode + 293
59  HIToolbox                           0x00007fff399a47eb ReceiveNextEventCommon + 618
60  HIToolbox                           0x00007fff399a4568 _BlockUntilNextEventMatchingListInModeWithFilter + 64
61  AppKit                              0x00007fff37c5f363 _DPSNextEvent + 997
62  AppKit                              0x00007fff37c5e102 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
63  AppKit                              0x00007fff37c58165 -[NSApplication run] + 699
64  Foundation                          0x00007fff3cb040c5 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 1123
65  Foundation                          0x00007fff3cb0bc6a -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 131
66  BitwigStudioEngine                  0x000000010b536cb3 main + 8099
67  libdyld.dylib                       0x00007fff6795fed9 start + 1
68  ???                                 0x0000000000000003 0x0 + 3

Yes, we are struggling with this bug too. I’m pretty sure it is caused by fonts in custom data. I’ve spent a lot of time digging into the juce code and I can’t see anything wrong. I think the bug was introduced in a recent version of macOS.

My only advice is to create your custom Typeface only once, maybe in a singleton. The more Typefaces you create, the more likely you are to get a crash.

Other related threads:

1 Like

Can you build and run my test app CrazyFonts, found here: https://github.com/FigBug/juce_bugs/tree/master/CrazyFonts and let me know the results. Make sure the window is showing and the screensaver doesn’t come on so that it’s continually painting.

Ok, I did. I see lots of crazy coloured fonts. What now? There’s no output. What results should I post?

Let it run for a few hours when you don’t need your machine. How much memory is it using / how much memory does the kernel use? Does the painting get slower and slower? Does it eventually crash / lock up / crash your machine?

On my Trash Can Mac Pro I eventually get a Kernel Panic:

Anonymous UUID:       E2963E78-DB30-EBDE-59C8-3A0656C5B180

Sun Apr 21 13:17:43 2019

*** Panic Report ***
panic(cpu 2 caller 0xffffff8010c3176c): "trying to interlock destroyed mutex (0xffffff8078e71000)"@/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu/xnu-4903.251.3/osfmk/i386/locks_i386.c:2749

On my MacBook Pro it just gets slower and slower and the Kernel Memory Usage gets up to about 5 GB.

My goal is to reproduce the crash you are seeing above, so far I can’t do it. But I am getting other weird behaviour.

Ok so we are getting the crash trace from my first post about once a week.
I’m running the program @RolandMR linked for a while now. It never crashes but is regularly hangs for a variable period of time.

We are also seeing missing glyphs instead of crashes from time to time.
We are using a combination of AttributedString and Textlayout, if that helps.

I’d be very happy if this can somehow be fixed.

I’m still trying to find a reliable way to reproduce this bug. This is our #1 mac crash, if anybody has any ideas on how to fix or work around I’d be very interested to hear.

What embedded fonts are you using? I’m wondering if there is some way to write them to disk, install them, and load them as regular fonts , to work around?

We are using Apercu cuts as .otf.
Installing fonts to a users computer sounds like it would cause some legal issues, since we bought that font.

Have you ever tried your test program as a plugin instead of a standalone version?

No, I haven’t tried that. Might be worth trying. But I am seeing these crashes in our App as well. Maybe it’s a combination of juce based host / plugin that causes the issue? What host are you using?

We also have occasional crashes deep in OSX text layout code we cannot explain!

Ok, so we have this new stacktrace from a debug run:

__pthread_kill 0x00007fff7481f2c6
pthread_kill 0x00007fff748dabf1
abort 0x00007fff747896a6
malloc_vreport 0x00007fff74898077
malloc_zone_error 0x00007fff748b0e0d
tiny_malloc_from_free_list 0x00007fff74890f17
tiny_malloc_should_clear 0x00007fff7489043b
szone_malloc_should_clear 0x00007fff7489020f
malloc_zone_malloc 0x00007fff7488ec99
CFBasicHashCreateCopy 0x00007fff48784117
CFDictionaryCreateMutableCopy 0x00007fff48783e61
TCFMutableDictionary::TCFMutableDictionary(__CFDictionary const*, long) 0x00007fff4a38405a
CTFontDescriptorCreateCopyWithAttributes 0x00007fff4a3cd2c1
CTFontCreateCopyWithAttributes 0x00007fff4a3cd1dc
TAttributes::CopyOfFontWithLigatureSetting(__CTFont const*, LigatureSetting) 0x00007fff4a3ebe21
TAttributes::ApplyFont(__CFDictionary const*, __CTFont const*, void const**) 0x00007fff4a3b5c16
TAttributes::TAttributes(__CFDictionary const*) 0x00007fff4a3b5947
TTypesetterAttrString::Initialize(__CFAttributedString const*) 0x00007fff4a3c260c
TTypesetterAttrString::TTypesetterAttrString(__CFAttributedString const*, __CFDictionary const*) 0x00007fff4a3c2379
CTLineCreateWithAttributedString 0x00007fff4a3c21ca
juce::OSXTypeface::getGlyphPositions(juce::String const&, juce::Array<int, juce::DummyCriticalSection, 0>&, juce::Array<float, juce::DummyCriticalSection, 0>&) juce_mac_Fonts.mm:609
juce::Font::getGlyphPositions(juce::String const&, juce::Array<int, juce::DummyCriticalSection, 0>&, juce::Array<float, juce::DummyCriticalSection, 0>&) const juce_Font.cpp:649
juce::GlyphArrangement::addCurtailedLineOfText(juce::Font const&, juce::String const&, float, float, float, bool) juce_GlyphArrangement.cpp:152
juce::GlyphArrangement::addLineOfText(juce::Font const&, juce::String const&, float, float) juce_GlyphArrangement.cpp:141
juce::GlyphArrangement::addFittedText(juce::Font const&, juce::String const&, float, float, float, float, juce::Justification, int, float) juce_GlyphArrangement.cpp:324
juce::Graphics::drawFittedText(juce::String const&, juce::Rectangle<int>, juce::Justification, int, float) const juce_GraphicsContext.cpp:326
juce::LookAndFeel_V2::drawLabel(juce::Graphics&, juce::Label&) juce_LookAndFeel_V2.cpp:1248
juce::Label::paint(juce::Graphics&) juce_Label.cpp:336
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1905
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::Component::paintWithinParentContext(juce::Graphics&) juce_Component.cpp:1889
juce::Component::paintComponentAndChildren(juce::Graphics&) juce_Component.cpp:1950
juce::Component::paintEntireComponent(juce::Graphics&, bool) juce_Component.cpp:2008
juce::ComponentPeer::handlePaint(juce::LowLevelGraphicsContext&) juce_ComponentPeer.cpp:133
juce::NSViewComponentPeer::invokePaint(juce::LowLevelGraphicsContext&) juce_mac_NSViewComponentPeer.mm:958
juce::NSViewComponentPeer::drawRect(CGContext*, CGRect, float) juce_mac_NSViewComponentPeer.mm:861
juce::NSViewComponentPeer::drawRect(CGRect) juce_mac_NSViewComponentPeer.mm:852
juce::JuceNSViewClass::drawRect(objc_object*, objc_selector*, CGRect) juce_mac_NSViewComponentPeer.mm:1661
_NSViewDrawRect 0x00007fff45ea921e
-[NSView _drawRect:clip:] 0x00007fff45e9405e
-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] 0x00007fff45e91fe1
-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] 0x00007fff45e91798
-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] 0x00007fff45e91798
-[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] 0x00007fff45e90b8e
-[NSView _oldDisplayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] 0x00007fff45e8e490
-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] 0x00007fff45e8dac9
-[NSView displayIfNeeded] 0x00007fff45e8a6be
-[NSWindow displayIfNeeded] 0x00007fff45e873ff
__NSWindowGetDisplayCycleObserverForDisplay_block_invoke 0x00007fff45e87240
NSDisplayCycleObserverInvoke 0x00007fff45e82334
NSDisplayCycleFlush 0x00007fff45e81eb4
CA::Transaction::run_commit_handlers(CATransactionPhase) 0x00007fff531f454d
CA::Transaction::commit() 0x00007fff531f3d26
__65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke 0x00007fff45e8184d
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 0x00007fff487e7688
__CFRunLoopDoObservers 0x00007fff487e75bd
__CFRunLoopRun 0x00007fff48789ce0
CFRunLoopRunSpecific 0x00007fff4878961e
RunCurrentEventLoopInMode 0x00007fff479e81ab
ReceiveNextEventCommon 0x00007fff479e7ded
_BlockUntilNextEventMatchingListInModeWithFilter 0x00007fff479e7c76
_DPSNextEvent 0x00007fff45d8077d
-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x00007fff45d7f46b
-[NSApplication run] 0x00007fff45d79588
-[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] 0x00007fff4aa7c828
-[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] 0x00007fff4aa84252
main 0x0000000108c4e042
start 0x00007fff746e43d5
start 0x00007fff746e43d5

Crashes on this line:

Maybe this is of any help.

1 Like

I’ve been having this exact crash (same line number) a lot today. Interestingly, it only affected Debug builds, not Release builds. If I get it again, I’ll post the trace.

Edit: This is with a custom font (only loaded once when the app launches). MacOS 10.14.6. The crash happens when loading components with the custom font well after the app launched.

Just had this crash on iOS in the Simulator!

Same line as above:

This time it crashed on load. Only for debug builds.

I’ve had similar issues recently on a Standalone desktop app… using stock fonts.

Rail

Any updates on this. I’ve had to give a few refunds on these crashes.

We’ve fixed some macOS font rendering issues on the develop branch:

1 Like