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

[MYBackgroundMonitor hasBackgroundTask]: message sent to deallocated instance #1677

Closed
nmeziere opened this issue Mar 22, 2017 · 2 comments
Closed

Comments

@nmeziere
Copy link

nmeziere commented Mar 22, 2017

Hi,

I have a crash concerning the MYBackgroundMonitor project. I have no steps to reproduce, only a stacktrace :

-[MYBackgroundMonitor hasBackgroundTask]: message sent to deallocated instance 0x17484bd60

Thread 1Queue : com.apple.main-thread (serial)
#0 0x00000001856151c4 in forwarding ()
#1 0x000000018550e80c in _CF_forwarding_prep_0 ()
#2 0x00000001004400e0 in __56-[CBLRestReplicator(Backgrounding) okToEndBackgrounding]_block_invoke at couchbase-lite-ios/Source/CBLRestReplicator+Backgrounding.m:70
#3 0x00000001044c9258 in _dispatch_call_block_and_release ()
#4 0x00000001044c9218 in _dispatch_client_callout ()
#5 0x00000001044ce280 in _dispatch_main_queue_callback_4CF ()
#6 0x00000001855be810 in CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE ()
#7 0x00000001855bc3fc in __CFRunLoopRun ()
#8 0x00000001854ea2b8 in CFRunLoopRunSpecific ()
#9 0x0000000186f9e198 in GSEventRunModal ()
#10 0x000000018b5317fc in -[UIApplication _run] ()
#11 0x000000018b52c534 in UIApplicationMain ()
#13 0x00000001844cd5b8 in start ()
Enqueued from com.apple.root.default-qos.overcommit (Thread 58)Queue : com.apple.root.default-qos.overcommit (serial)
#0 0x00000001044d4b30 in _dispatch_queue_push ()
#1 0x0000000100440098 in -[CBLRestReplicator(Backgrounding) okToEndBackgrounding] at couchbase-lite-ios/Source/CBLRestReplicator+Backgrounding.m:69
#2 0x00000001003d57d0 in -[CBLRestReplicator updateActive] at couchbase-lite-ios/Source/CBLRestReplicator.m:521
#3 0x00000001003d674c in __45-[CBLRestReplicator fetchRemoteCheckpointDoc]_block_invoke at couchbase-lite-ios/Source/CBLRestReplicator.m:759
#4 0x00000001003ee214 in -[CBLRemoteRequest respondWithResult:error:] at couchbase-lite-ios/Source/CBLRemoteRequest.m:192
#5 0x00000001003efea0 in -[CBLRemoteJSONRequest didFinishLoading] at couchbase-lite-ios/Source/CBLRemoteRequest.m:600
#6 0x000000010041bfd0 in __57-[CBLRemoteSession URLSession:task:didCompleteWithError:]_block_invoke at couchbase-lite-ios/Source/CBLRemoteSession.m:329
#7 0x0000000186125048 in __NSThreadPerformPerform ()
#8 0x00000001855beb5c in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
#9 0x00000001855be4a4 in __CFRunLoopDoSources0 ()
#10 0x00000001855bc0a4 in __CFRunLoopRun ()
#11 0x00000001854ea2b8 in CFRunLoopRunSpecific ()
#12 0x000000018602726c in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#13 0x00000001003d200c in -[CBL_RunLoopServer runServerThread] at couchbase-lite-ios/Source/CBL_Server.m:193
#14 0x0000000186124e68 in NSThread__start ()
#15 0x00000001846a5850 in _pthread_body ()
#16 0x00000001846a5760 in _pthread_start ()
#17 0x00000001846a2d94 in thread_start ()

CouchbaseLite (58)#0 0x0000000184056f80 in objc_opt::objc_stringhash_t::getIndex(char const*) const ()
#1 0x0000000184056ebc in objc_opt::objc_selopt_t::get(char const*) const ()
#2 0x0000000184056d64 in __sel_registerName(char const*, int, int) ()
#3 0x0000000184054450 in fixupMethodList(method_list_t*, bool, bool) ()
#4 0x0000000184053d3c in prepareMethodLists(objc_class*, method_list_t**, int, bool, bool) ()
#5 0x000000018404d350 in realizeClass(objc_class*) ()
#6 0x000000018404abec in _class_getNonMetaClass ()
#7 0x0000000184050c50 in lookUpImpOrForward ()
#8 0x000000018405b298 in _objc_msgSend_uncached ()
#9 0x00000001003d75dc in -[CBLRestPuller startChangeTracker] at couchbase-lite-ios/Source/CBLRestPuller.m:107
#10 0x00000001003d7498 in -[CBLRestPuller beginReplicating] at couchbase-lite-ios/Source/CBLRestPuller.m:94
#11 0x00000001003d6700 in __45-[CBLRestReplicator fetchRemoteCheckpointDoc]_block_invoke at couchbase-lite-ios/Source/CBLRestReplicator.m:757
#12 0x00000001003ee214 in -[CBLRemoteRequest respondWithResult:error:] at couchbase-lite-ios/Source/CBLRemoteRequest.m:192
#13 0x00000001003efea0 in -[CBLRemoteJSONRequest didFinishLoading] at couchbase-lite-ios/Source/CBLRemoteRequest.m:600
#14 0x000000010041bfd0 in __57-[CBLRemoteSession URLSession:task:didCompleteWithError:]_block_invoke at couchbase-lite-ios/Source/CBLRemoteSession.m:329
#15 0x0000000186125048 in __NSThreadPerformPerform ()
#16 0x00000001855beb5c in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
#17 0x00000001855be4a4 in __CFRunLoopDoSources0 ()
#18 0x00000001855bc0a4 in __CFRunLoopRun ()
#19 0x00000001854ea2b8 in CFRunLoopRunSpecific ()
#20 0x000000018602726c in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#21 0x00000001003d200c in -[CBL_RunLoopServer runServerThread] at couchbase-lite-ios/Source/CBL_Server.m:193
#22 0x0000000186124e68 in NSThread__start ()
#23 0x00000001846a5850 in _pthread_body ()
#24 0x00000001846a5760 in _pthread_start ()
#25 0x00000001846a2d94 in thread_start ()


Version: 1.3.1
Client OS: IOS 10.2.1

@pasin
Copy link
Contributor

pasin commented Mar 22, 2017

I haven't investigated the issue yet but in 1.4.0 @snej did some improvement and fixed some issues around backgrounding. You may try with 1.4.0 release and see if it helps the issue.

@nmeziere
Copy link
Author

Hi,

I made a mistake concerning the version of CouchBase embedded in our app. We use a version of CouchBase based on a specific commit (74f02a9).

The diff between our version and the last CouchBase release v1.4 is :
74f02a9...release/1.4.0

It seems there are only unit test changes. So the bug should not be fixed in the release 1.4.

Best regards,

@djpongh djpongh added the icebox label Apr 21, 2017
pasin added a commit that referenced this issue Aug 28, 2017
* There is a race condition between resetting _bgMonitor to nil in -endBackground on the replicator thread and accessing _bgMonitor in -okToEndBackgrounding on the main thread.

* The easiest way to fix this is to not resetting nil after stopping the bgMonitor given the fact that it could also be recreated again from the replicator thread in the -setupBackgrounding method.

#1677 #CBSE-4145
@pasin pasin closed this as completed Aug 28, 2017
@pasin pasin removed the icebox label Aug 28, 2017
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

3 participants