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

CBL 1.0.4 - Rare/minor dealloc issue #592

Closed
nl opened this issue Feb 10, 2015 · 6 comments
Closed

CBL 1.0.4 - Rare/minor dealloc issue #592

nl opened this issue Feb 10, 2015 · 6 comments

Comments

@nl
Copy link

nl commented Feb 10, 2015

For some reason, using CBL 1.0.4 and creating/starting/stopping replications every few seconds, I got this random crash. It happened only once, but just in case someone's interested... https://gist.github.com/nl/0e6911935526abf090aa

@snej
Copy link
Contributor

snej commented Feb 10, 2015

Interesting — both the main thread and the replicator thread are dealloc'ing a CBLReplication, with nearly identical stacks. If it's the same instance, then that would explain the crash. But it shouldn't be possible for an object's -dealloc to be called on multiple threads, since ref-counting is thread-safe.

On the other hand, it could be different CBLReplication instances, in which case it's just a very weird coincidence that both threads are in almost the same state.

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8f3cca0e sigprocmask + 10
1   libsystem_malloc.dylib          0x00007fff88350937 free + 428
2   libobjc.A.dylib                 0x00007fff899c804c object_dispose + 54
3   com.couchbase.CouchbaseLite     0x00000001092393b9 -[CBLReplication dealloc] + 169
4   libobjc.A.dylib                 0x00007fff899e068c objc_object::sidetable_release(bool) + 236
...

Thread 4 Crashed:: CouchbaseLite
0   libsystem_kernel.dylib          0x00007fff8f3cb282 __pthread_kill + 10
1   libsystem_c.dylib               0x00007fff92ea6b73 abort + 129
2   libsystem_malloc.dylib          0x00007fff88350937 free + 428
3   libobjc.A.dylib                 0x00007fff899c804c object_dispose + 54
4   com.couchbase.CouchbaseLite     0x00000001092393b9 -[CBLReplication dealloc] + 169
5   libobjc.A.dylib                 0x00007fff899e068c objc_object::sidetable_release(bool) + 236
...

@pasin pasin added the ready label Feb 19, 2015
@pasin
Copy link
Contributor

pasin commented Feb 19, 2015

@nl I plan to look at this issue some time this week or early next week. I would need to gather some more information and hopefully I can reproduce this. Look like we have ARC race condition here.

Are you using continuous replicators?
Are you using push or pull or both? Do you know which one crashed?
Do I understand correctly that when you called the replicator's stop method, you created a new replicator immediately on a main thread without any delays in between?

@nl
Copy link
Author

nl commented Feb 21, 2015

In my tests, I'm using both push and pull, mixed continuous and non-continuous replications. You're right about the no-delay: I'm stopping a replication and creating/starting a similar one immediately. I do this every few seconds. Here's a similar crash: https://gist.github.com/nl/9e94ebc9293073105ce4. It's not dealloc anymore, but it only happens in this same scenario (rapid creation/deletion of replications).

@pasin
Copy link
Contributor

pasin commented Feb 26, 2015

I was trying to reproduce but still no luck. I have setup 2 pushers (one-time and continuous) and 2 pullers (one-time and continuos). I started, stopped and recreated those replicators every 2 seconds for 200 times, and everything worked as expected. I tested this on a mac app as I remembered that you are developing a mac application (let me know if I'm wrong).

Anyway, does this issue happen to you again? and would it possible to post your code snippets showing how you setup the replicators and how you start/stop them in everything few seconds? If you have any other things or steps that you suspect to cause this issue, please feel free to provide.

@nl
Copy link
Author

nl commented Feb 27, 2015

You're right about the Mac thing. I worked around the issue using your first hint: I start the 'new' replication after a slight runloop delay instead of right away after issuing the async stop on the 'old' replication.

@pasin
Copy link
Contributor

pasin commented Feb 28, 2015

I'm closing this ticket now as I cannot reproduce but I will keep an eye on this. Feel free to reopen the ticket if you encounter the issue again or have more information that can help investigating the issue. Thanks a lot anyway for reporting the issue.

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

No branches or pull requests

4 participants