CGImageSourceGetStatusAtIndex crashes in [CIFilter dealloc]

I see random crashes in CGImageSourceGetStatusAtIndex on macOS. These crashes happen for customers. So far I have not been able to recreate the problem. I assume it is triggered by certain image file types.


The stack trace looks like this:


Exception Type: SIGSEGV
Exception Codes: SEGV_MAPERR at 0x618d29ccbec0
Crashed Thread: 12

0   libobjc.A.dylib                      0x00007fff6533de9d objc_msgSend + 29
1   CoreImage                            0x00007fff3e690da6 -[CIFilter dealloc] + 269
2   libobjc.A.dylib                      0x00007fff65345db4 _ZN11objc_object17sidetable_releaseEb + 266
3   libobjc.A.dylib                      0x00007fff65341087 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 817
4   RawCamera                            0x00007fff361f5758 RCCreateCIImageFromBufferAndProperties + 209389
5   RawCamera                            0x00007fff361b9631 GetRawPluginsInfo + 214413
6   RawCamera                            0x00007fff361ba651 GetRawPluginsInfo + 218541
7   RawCamera                            0x00007fff361c140b GetRawPluginsInfo + 246631
8   ImageIO                              0x00007fff40520554 _ZN14IIOImageSource13makeImagePlusEmP13IIODictionary + 466
9   ImageIO                              0x00007fff40521791 _ZN14IIOImageSource28getPropertiesAtIndexInternalEmP13IIODictionary + 49
10  ImageIO                              0x00007fff40521715 _ZN14IIOImageSource21copyPropertiesAtIndexEmP13IIODictionary + 11
11  ImageIO                              0x00007fff404f7d42 CGImageSourceCopyPropertiesAtIndex + 237


My code runs on a background thread:


CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);

if (source)
{
     CGImageSourceStatus status = CGImageSourceGetStatus(source);
     if ((status == kCGImageStatusComplete) && (CGImageSourceGetCount(source)))
     {
          CFDictionaryRef propsCF = CGImageSourceCopyPropertiesAtIndex(source,  0,  NULL );

          if (propsCF)
          {
               …
               CFRelease(propsCF);
          }
          CFRelease(source);
     }
}


I hope this rings a bell with someone.


I can't find any word on the thread safety of CGImageSourceCopyPropertiesAtIndex. Until recently it has not been a problem though.

I can't see what I could be doing wrong here. Again, this used to work fine. And mostly does. Except for some customers or some file types.


Could this be a question for DTS code level support?