Crashes in CoreGraphics?

I’ve been seeing a fair number of crashes in Studio One and Reaper, in different places, but often in code where we are simply drawing some lines or rectangles or text. Below is a portion of a crash log showing one such crash I have seen. I understand the note that an “object was probably modified after being freed”, but trying to see what object it is is difficult, since it happens so randomly. I just don’t get why drawing a line would cause this kind of crash. Any ideas where I can look? Could it be something in VSTGUI itself?

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
*** error for object 0x7faf125bcc00: incorrect checksum for freed object - object was probably modified after being freed.


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fffe414dd42 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fffe423b5bf pthread_kill + 90
2 libsystem_c.dylib 0x00007fffe40b3420 abort + 129
3 libsystem_malloc.dylib 0x00007fffe41adf5d szone_error + 626
4 libsystem_malloc.dylib 0x00007fffe41af925 small_free_list_remove_ptr_no_clear + 766
5 libsystem_malloc.dylib 0x00007fffe41a390e small_malloc_from_free_list + 394
6 libsystem_malloc.dylib 0x00007fffe41a1953 szone_malloc_should_clear + 1649
7 libsystem_malloc.dylib 0x00007fffe41a1282 malloc_zone_malloc + 107
8 libsystem_malloc.dylib 0x00007fffe41a0200 malloc + 24
9 com.apple.CoreGraphics 0x00007fffcec176b0 aal_create + 164
10 com.apple.CoreGraphics 0x00007fffceba33cf ripr_Acquire + 124
11 com.apple.CoreGraphics 0x00007fffceba3250 RIPRenderPath + 73
12 com.apple.CoreGraphics 0x00007fffce90d6fa ripc_DrawPath + 346
13 com.apple.AppKit 0x00007fffcc40c364 __backing_store_DrawPath_block_invoke + 35
14 com.apple.AppKit 0x00007fffcc11e15b backing_store_delegate + 984
15 com.apple.AppKit 0x00007fffcc40b937 backing_store_DrawPath + 475
16 com.apple.CoreGraphics 0x00007fffceb458ea CGContextDrawPath + 182
17 com.Antares.AutoTune.vst3 0x000000012ca52087 VSTGUI::CGDrawContext::drawLine(std::__1::pair<VSTGUI::CPoint, VSTGUI::CPoint> const&) + 423 (cgdrawcontext.cpp:395)
18 com.Antares.AutoTune.vst3 0x000000012ca1c654 VSTGUI::CDrawContext::drawLine(VSTGUI::CPoint const&, VSTGUI::CPoint const&) + 180 (cdrawcontext.h:90)

Turn on “AddressSanitizer” in Xcode/clang. This should give you more clue where this comes from. I would guess, that you’re overwriting memory somewhere.

Yep, you are correct. I was requesting a buffer of data, passing the length of the buffer instead of the last position in the buffer as required, which would be the length minus 1. That one extra write overwrites whatever just happens to be in the memory location after the buffer, thus the randomness of the crash. Sorry for the noise. Been debugging for days, and only after I break down and ask someone do I find the cause (of this and several other apparently random crashes). :slight_smile: