I'm using QTouchposeApplication library (particularly a class TRTouchposeApplication from develop branch).
There were crashes in one of the execution paths in master branch, and the author fixed them in develop branch. However, one of the crashes is still present.
Let's say we have a CF-dictionary, which stores UITouch objects without retaining them:
// Dictionary of touches being displayed. Keys are UITouch pointers and values are UIView pointers that visually represent
// the touch on-screen. (A CFMutableDictionaryRef is used because NSDictionary requries its keys to conform to the
// NSCopying protocol and UITouch doesn't. We don't need to retain either the UITouch or UIView instances because UITouch
// objects are persistent throughout a multi-touch sequence, and the UIViews are retained by their superview.)
CFMutableDictionaryRef _touchDictionary;
We add UITouch to the dictionary like this:
CFDictionarySetValue(_touchDictionary, (__bridge const void *)(touch), (__bridge const void *)(someUIView));
Then at some point UITouch is released by the system (I'm using ARC in my project).
So when we try to "unwrap" the touch, it crashes. I've got a message -[UITouch retain]: message sent to deallocated instance with Xcode Address Sanitizer:
So the reason of the crash is that we are storing ARC-objects as void*, so __bridge crashes if this object was deallocated.
I've seen __bridge, __bridge_transfer, __bridge_retained, but didn't see smth like bridge_TRY.
In order to write a patch for this crash, I'd like to know:
- Can we "safely bridge" somehow in this case, and get a result
UITouch = nil, if touch was deallocated. - Can we somehow subscribe for "UITouch" deallocation, so that we delete a corresponding
UITouchfromCFDictionarybefore the touch object will be deleted and pointer invalid? - Are there the other ways to handle this?

In line 83 you use cycle
forfor check each dictionary value, but in line 91 you change dictionary size. So better to add otheroutputDictionaryat the line 77, that would be equal_touchDictionary, and in line 91 remove data fromoutputDictionary, and in line 95 set_touchDictionary = outputDictionaryback.It would be more safety