Crash if custom object in GSLayer.userData exceeds 5MB

I have a custom object in GSLayer.userData which returns its serialized form via the -description method as recommended in the docs.

This works perfectly fine unless the NSString returned from -description exceeds around 5MB, in which case the app crashes on writePropertyListToFileNoEscape when it tries to write the string.

Ideally a string of any length should be acceptable-- my use case requires this.

What version are you using? It should be fixed in the latest cutting edge version.

Iā€™m using the cutting edge Glyphs 2.5.2 (1172)

Attached is an example file that will crash if you attempt to edit and save the A glyph.

Newnew.zip (2.0 MB)

Relevant crash report
Process: Glyphs [741]
Path: /Applications/Glyphs.app/Contents/MacOS/Glyphs
Identifier: com.GeorgSeifert.Glyphs2
Version: 2.5.2 (1172)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Glyphs [741]
User ID: 501

Date/Time:             2018-10-23 16:19:43.660 +0400
OS Version:            Mac OS X 10.12.6 (16G1114)
Report Version:        12


Time Awake Since Boot: 690 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x00007fff534c62c8
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x7fff534c62c8:
    MALLOC_SMALL           00007ffdab000000-00007ffdac800000 [ 24.0M] rw-/rwx SM=PRV  
--> STACK GUARD            00007fff4fdf6000-00007fff535f6000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
    Stack                  00007fff535f6000-00007fff53df6000 [ 8192K] rw-/rwx SM=PRV  thread 0

Application Specific Information:
Performing @selector(saveDocument:) from sender NSMenuItem 0x6100000bc620

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.schriftgestaltung.GlyphsCore	0x000000010c391190 encodeString + 109
1   com.schriftgestaltung.GlyphsCore	0x000000010c390a7e encodePropertyList + 187
2   com.schriftgestaltung.GlyphsCore	0x000000010c390ed5 encodePropertyList + 1298
3   com.schriftgestaltung.GlyphsCore	0x000000010c391422 writePropertyListToFileNoEscape + 89
4   com.schriftgestaltung.GlyphsCore	0x000000010c28b8d1 -[GSLayer saveToFile:compact:error:] + 5509
5   com.schriftgestaltung.GlyphsCore	0x000000010c26dc83 -[GSGlyph saveToFile:compact:doLastChange:error:] + 1230
6   com.schriftgestaltung.GlyphsCore	0x000000010c366c93 -[GSFont(SerialSave) saveToFile:error:] + 3494
7   com.schriftgestaltung.GlyphsCore	0x000000010c365d0f -[GSFont(SerialSave) saveToURL:error:] + 1104
8   com.GeorgSeifert.Glyphs2      	0x000000010be1a35c 0x10be0a000 + 66396
9   com.apple.AppKit              	0x00007fff9f4eabb1 -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] + 915
10  com.apple.AppKit              	0x00007fff9f4eb8b7 -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:error:] + 28
11  com.apple.AppKit              	0x00007fff9ed5f89e -[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:] + 355
12  com.GeorgSeifert.Glyphs2      	0x000000010be194d3 0x10be0a000 + 62675

Thanks for the file. I fixed it.

1 Like