I'm attempting to migrate a Core Data SQLite store in my Mac OS X Leopard app. The m开发者_运维问答igration itself is simple, there's just a couple of changes between the model versions, and there's one custom NSEntityMigrationPolicy
that does a little bit of string manipulation.
99% of the time, this works perfectly. However, occasionally it crashes with EXC_BAD_ACCESS
in objc_assign_strongCast
under migrateStoreFromURL:
type:
options:
withMappingModel:
toDestinationURL:
destinationType:
destinationOptions:
error:
.
At this point, my custom migration policy hasn't been invoked, so I don't think that's causing it. I've also triple checked my mapping model file, and all seems to be well.
The kicker is that if I simply try to migrate the same file again, it normally works fine. I've no idea where to start debugging this, so any pointers would be welcome!
After speaking with DTS, it turns out this is a bug in Core Data on Mac OS X 10.6.
The workaround: Make sure you're not passing in a nil
error to migrateStoreFromURL: type: options: withMappingModel: toDestinationURL: destinationType: destinationOptions: error:
. This should be allowed, but in this case it causes a crash.
Two things:
- Use the tools Apple provides (namely, Instruments) to track down the memory management issue. It might still be somewhere in your own code.
- Try to reduce this to a simple, reproducible case and file a bug with Apple.*
I've noticed a lot of issues popping up surrounding 'automatic' migration that have given me serious pause. The only way to get them addressed is to make sure Apple is aware of every one of them.
精彩评论