-
Notifications
You must be signed in to change notification settings - Fork 45
mts_setValuesForKeysWithDictionary not thread-safe #17
Comments
Hello @jpmhouston, Thanks for posting your issue. We are currently caching all this data in these dictionaries to speed up Motis, as all the introspection calls are very slow (and we try to cache as much as possible the result of this introspection). Therefore, I would encourage you to NOT disable all the caching. However, what we can do is make Motis thread-safe, and protect those parts of the code that might be not thread safe, as the mutable dictionary manipulation. I'll be working on this as soon as I can (at some moment this week). However if meanwhile you want to try to fix it, you are more than welcome :). I'll keep you updated. |
Hi, I've also been seeing this issue for a while now, any news on a fix? Thanks |
Hello @R1ckye and @jpmhouston, Sorry for the delay. Version 1.0.2 Thread Safe of Motis is already available in Cocoa Pods. Please, test int and report any issue you find. I've been testing and I could not reproduce anymore any crash caused by non thread safe calls to dictionaries. Now, it still pending optimize a bit the synchronization done. I'll schedule it as my next task. Thanks, |
Hello @samkaufman and @jpmhouston, I've seen you have forked Motis and modified it to make it thread safe. For your information, Motis is from 1.0.2 now Thread Safe (and still using the objective-c runtime cache layer). Feel free to pull changes to your forked repository. Cheers, Joan |
@vilanovi This is fantastic. Thanks, Joan. Very happy to have the introspection result caches back. |
@samkaufman You are welcome!. And my apologies for the delay of solving this issue. I've been traveling and I could not do it before. ;) |
I've been seeing occasional crashes "error for object 0x7fbf1b42bbb0: pointer being freed was not allocated" in places like the
dictionary[typeAttribute] = isClassType;
line ofmts_isClassTypeTypeAttribute
.Searching the web for
NSMutableDictionary "pointer being freed was not allocated"
found http://stackoverflow.com/a/16976032 warning about "mutating the dictionary's contents on different threads at the same time", and I see that our app is indeed callingmts_setValuesForKeysWithDictionary
from within several occurrences of adispatch_async(dispatch_get_global_queue(..)
block.Can I get any tips for making
mts_setValuesForKeysWithDictionary
thread safe? I see several category methods in NSObject+Motis.m that use astatic NSMutableDictionary
to cache results for the same type, optimizations I can either disable or make thread-safe. Is there anything more subtle I also need to look at?The text was updated successfully, but these errors were encountered: