Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 9 - FCModelDatabaseQueue deadlock - any ideas? #124

Open
hartbit opened this issue Aug 24, 2015 · 1 comment
Open

iOS 9 - FCModelDatabaseQueue deadlock - any ideas? #124

hartbit opened this issue Aug 24, 2015 · 1 comment

Comments

@hartbit
Copy link

hartbit commented Aug 24, 2015

Recompiled my app for iOS 9, and I now have the main thread deadlocking with this stack trace:

Thread 1Queue : com.apple.main-thread (serial)
#0  0x00000001148ba136 in __psynch_cvwait ()
#1  0x0000000114882560 in _pthread_cond_wait ()
#2  0x00000001113dd24e in -[__NSOperationInternal _waitUntilFinished:] ()
#3  0x00000001113fe76a in -[NSOperationQueue addOperations:waitUntilFinished:] ()
#4  0x000000010fd76378 in -[FCModelDatabaseQueue execOnSelfSync:] at /Users/david/Projects/MyProject/Pods/FCModel/FCModel/FCModelDatabaseQueue.m:56
#5  0x000000010fd766a5 in -[FCModelDatabaseQueue inDatabase:] at /Users/david/Projects/MyProject/Pods/FCModel/FCModel/FCModelDatabaseQueue.m:76
#6  0x000000010fd65230 in +[FCModel instanceFromDatabaseWithPrimaryKey:] at /Users/david/Projects/MyProject/Pods/FCModel/FCModel/FCModel.m:196
#7  0x000000010fd64888 in +[FCModel instanceWithPrimaryKey:databaseRowValues:createIfNonexistent:] at /Users/david/Projects/MyProject/Pods/FCModel/FCModel/FCModel.m:147
#8  0x000000010fd644a7 in +[FCModel instanceWithPrimaryKey:createIfNonexistent:] at /Users/david/Projects/MyProject/Pods/FCModel/FCModel/FCModel.m:125
#9  0x00000001045a004c in -[MyModel myProperty] at /Users/david/Projects/MyProject/Sources/MyModel.m:593
#10 0x000000010629cfc7 in -[NSObject(NSKeyValueCoding) valueForKey:] ()
#11 0x00000001062b3c3a in -[NSKeyValueNestedProperty object:didAddObservance:recurse:] ()
#12 0x0000000106298a78 in -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] ()
#13 0x0000000106298704 in -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] ()
#14 0x000000010463872e in -[ATPDecorator addObserver:forKeyPath:options:context:] at /Users/david/Projects/MyProject/Sources/ATPDecorator.m:129

And the FCModelDatabaseQueue is deadlocked with this stack trace (much less useful to me):

Thread 4Queue : FCModelDatabaseQueue :: NSOperation 0x7f994b5d9690 (QOS: UTILITY) (serial)
#0  0x00000001148ba166 in __psynch_mutexwait ()
#1  0x000000011487f696 in _pthread_mutex_lock ()
#2  0x000000011137f238 in -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] ()
#3  0x0000000111381564 in -[__NSOperationInternal _start:] ()
#4  0x00000001113811f7 in __NSOQSchedule_f ()
#5  0x00000001145394bb in _dispatch_client_callout ()
#6  0x000000011451fa3c in _dispatch_queue_drain ()
#7  0x000000011451ef5d in _dispatch_queue_invoke ()
#8  0x0000000114521ba6 in _dispatch_root_queue_drain ()
#9  0x0000000114521615 in _dispatch_worker_thread3 ()
#10 0x0000000114881a9d in _pthread_wqthread ()
#11 0x000000011487f3dd in start_wqthread ()

The problem seems similar to the one I had a while back #42 when initWithFieldValues:existsInDatabaseAlready: listened to modifications using KVO. I'm saying that because the queue's waiting in a _changeValueForKey:key:key:usingBlock: method and the main thread is in a addObserver:forKeyPath:options:context: call.

What I don't understand is why the queue thread is waiting even before the block added to FCModelDatabaseQueue is called. I differ the assembler of _changeValueForKey:key:key:usingBlock: and it has heavily changed between iOS 8 and iOS 9, with some locking method calls removed.

BUT, I can't seem to reproduce the problem in a test project.

@hartbit hartbit changed the title FCModelDatabaseQueue deadlock - any ideas? iOS 9 - FCModelDatabaseQueue deadlock - any ideas? Aug 24, 2015
@dustturtle
Copy link

FCModelDatabaseQueue already removed? I can not see anything about queue now! multi thread usage unsupported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants