GrahamDennis / GDCoreDataConcurrencyDebugging

GDCoreDataConcurrencyDebugging helps you find cases where NSManagedObject's are being called on the wrong thread or dispatch queue.
MIT License
170 stars 23 forks source link

[Question]*** -[NSTaggedPointerStringCStringContainer retain] called, not supposed to happen #24

Open simonbromberg opened 8 years ago

simonbromberg commented 8 years ago

If I call GDCoreDataConcurrencyDebuggingBeginTrackingAutorelease(), I get many logs saying

*\ -[NSTaggedPointerStringCStringContainer retain] called, not supposed to happen

Any idea what this means, how to fix it, and if it is a problem what is the effect? Can't even find where this message is called in the library.

Thanks

GrahamDennis commented 8 years ago

GDCoreDataConcurrencyDebugging does a bunch of hackery to get its job done. The autorelease tracking works by retaining objects that are sent autorelease messages and keeping track of the stacktrace for the original callstack where autorelease was sent.

So if you have code that looks like:

GDCoreDataConcurrencyDebuggingBeginTrackingAutorelease();

[myTaggedPointerStringCStringContainer autorelease]; // I don't actually know what this class is, but it's probably something internal to Apple.

GDCoreDataConcurrencyDebuggingEndTrackingAutorelease();

then when autorelease is called on myTaggedPointerStringCStringContainer, it will be sent a retain message.

So the upshot is feel free to ignore this, but there are a couple of steps that could be taken to avoid this:

  1. Don't try to track autorelease for tagged-pointer objects. These aren't 'normal' objects, and it doesn't make sense to track autorelease for these.
  2. We only actually want to track autorelease for CoreData-related classes, primarily NSManagedObject. Restrict tracking of autoreleases to just these classes.
GrahamDennis commented 8 years ago

Both of these require changes to - (id)gd_autorelease at the bottom of GDConcurrencyCheckingManagedObject. Feel free to submit a PR for this.