google / gtm-oauth2

Google Toolbox for Mac - OAuth 2 Controllers
Apache License 2.0
126 stars 70 forks source link

Sample app crashes in webcore after grant access action #66

Closed fornaxM closed 8 years ago

fornaxM commented 8 years ago

I've been trying to use the library for an OS X Application and for non google OAuth services, the sample app included with the bundle and the one I made with the usage instructions crash before the control reaching the callback - (void)viewController:(GTMOAuthViewControllerTouch )viewController finishedWithAuth:(GTMOAuthAuthentication )auth

I've attached the crash logs for your reference. Archive.zip

gmrobbins commented 8 years ago

I'm not seeing a problem signing in to a Google service using the OAuth 2 sample app on OS X 10.11.4.

From the crash logs, it looks like the crash is occurring inside WebCore::ResourceLoader::willSendRequestInternal.

Is the sign in to a non-Google server? I wonder if there's an issue in the OS networking stack.

fornaxM commented 8 years ago

Yes, this is happening only for a non-google server.

thomasvl commented 8 years ago

Doesn't seem like the code from this project is in any of those crash logs, so it is sorta hard to guess what might be happening. Without more info, you'll likely have to debug it on your end. My guess would be something is causing the webview to shutdown/navigate in a different way, and something ends up with a stale reference.

fornaxM commented 8 years ago

This is the last few lines of code on a different thread that I can see while I debug the issue. I've spent quite some time on debugging this now with no success and eventually decided to file this issue.

Thread 31Queue : com.apple.NSURLSession-work (serial)

0 0x00007fff8a4b50f0 in **CFBasicHashAddValue ()

1 0x00007fff8a4b667d in CFDictionarySetValue ()

2 0x00007fff94df3351 in HTTPHeaderDict::setValue(HTTPHeaderKeyMixedValue const&, HTTPHeaderValueMixedValue const&) ()

3 0x00007fff94e1b083 in HTTPMessage::setHeaderFieldScalarValue(CFNetworkConstantString::HTTPHeader::DomainString, long long) ()

4 0x00007fff94e1af63 in URLRequest::setHTTPBodyParts(_CFArray const) ()

5 0x00007fff94df4d3d in -[__NSURLSessionLocal _onqueue_connectUploadTask:strippedRequest:bodyStream:bodyParts:]()

6 0x00007fff94df3f56 in -[__NSCFLocalSessionTask _onqueue_completeInitialization]()

7 0x00007fff94df3df8 in 30-[NSCFURLSessionTask resume]_block_invoke ()

8 0x0000000100097070 in _dispatch_call_block_and_release ()

9 0x0000000100089cc5 in _dispatch_client_callout ()

10 0x000000010008f112 in _dispatch_queue_drain ()

11 0x0000000100096e24 in _dispatch_queue_invoke ()

12 0x000000010008ddab in _dispatch_root_queue_drain ()

13 0x000000010008d8a5 in _dispatch_worker_thread3 ()

14 0x00000001000ec336 in _pthread_wqthread ()

15 0x00000001000e9f91 in start_wqthread ()

Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)

0 0x000000010008ccb7 in _dispatch_barrier_async_f_slow ()

1 0x00007fff94df3d33 in -[__NSCFURLSessionTask resume]()

2 0x0000000100013117 in -[GTMSessionFetcher beginFetchMayDelay:mayAuthorize:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:797

3 0x000000010000ef4c in -[GTMSessionFetcher beginFetchWithCompletionHandler:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:327

4 0x000000010000fdc4 in -[GTMSessionFetcher beginFetchWithDelegate:didFinishSelector:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:354

5 0x0000000100004b78 in -[GTMOAuth2Authentication beginTokenFetchWithDelegate:didFinishSelector:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2Authentication.m:858

6 0x0000000100009637 in -[GTMOAuth2SignIn authCodeObtained] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2SignIn.m:524

7 0x0000000100009202 in -[GTMOAuth2SignIn requestRedirectedToRequest:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2SignIn.m:428

8 0x000000010000cbc5 in -[GTMOAuth2WindowController webView:resource:willSendRequest:redirectResponse:fromDataSource:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2WindowController.m:473

9 0x00007fff935f6723 in CallResourceLoadDelegate(void ()(), WebView, objcselector, objcobject, objcobject, objcobject, objcobject) ()

10 0x00007fff9358456d in WebFrameLoaderClient::dispatchWillSendRequest(WebCore::DocumentLoader_, unsigned long, WebCore::ResourceRequest&, WebCore::ResourceResponse const&) ()

11 0x00007fff827674ec in WebCore::ResourceLoadNotifier::dispatchWillSendRequest(WebCore::DocumentLoader_, unsigned long, WebCore::ResourceRequest&, WebCore::ResourceResponse const&) ()

12 0x00007fff833c6c5c in WebCore::ResourceLoader::willSendRequestInternal(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) ()

13 0x00007fff834d64c8 in WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) ()

14 0x00007fff8276ae5c in WebCore::ResourceHandle::willSendRequest(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) ()

15 0x00007fff82769c46 in -[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]()

16 0x00007fff94e11c01 in ___ZL31_NSURLConnectionWillSendRequestP16_CFURLConnectionPK13_CFURLRequestP14_CFURLResponsePKv_block_invoke ()

17 0x00007fff94e11b49 in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke ()

18 0x00007fff94e11a5e in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]()

19 0x00007fff94e11963 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:]()

20 0x00007fff94e118fa in _NSURLConnectionWillSendRequest(CFURLConnection, CFURLRequest const, CFURLResponse, void const_) ()

21 0x00007fff94fabcd1 in ___ZN27URLConnectionClient_Classic39_delegate_willSendRequestForRedirectionEPK12NSURLRequestP14_CFURLResponseU13block_pointerFvS2_E_block_invoke ()

22 0x00007fff94fab519 in ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 ()

23 0x0000000100089cc5 in _dispatch_client_callout ()

24 0x0000000100099e08 in _dispatch_block_invoke ()

25 0x00007fff94e11820 in RunloopBlockContext::_invokeblock(void const, void_) ()

26 0x00007fff8a4f7d74 in CFArrayApplyFunction ()

27 0x00007fff94e11719 in RunloopBlockContext::perform() ()

28 0x00007fff94e115ba in MultiplexerSource::perform() ()

29 0x00007fff94e113dc in MultiplexerSource::_perform(void*) ()

30 0x00007fff8a555881 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION** ()

31 0x00007fff8a534fbc in __CFRunLoopDoSources0 ()

32 0x00007fff8a5344df in __CFRunLoopRun ()

33 0x00007fff8a533ed8 in CFRunLoopRunSpecific ()

34 0x00007fff87b56935 in RunCurrentEventLoopInMode ()

35 0x00007fff87b5676f in ReceiveNextEventCommon ()

36 0x00007fff87b565af in _BlockUntilNextEventMatchingListInModeWithFilter ()

37 0x00007fff8bbb9efa in _DPSNextEvent ()

38 0x00007fff8bbb932a in -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:]()

39 0x00007fff8bbade84 in -[NSApplication run]()

40 0x00007fff8bb7746c in NSApplicationMain ()

41 0x0000000100007612 in main at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/main.m:12

42 0x00007fff885c75ad in start ()

I will continue to debug and post any updates. It would be great to get any pointers from anyone else who has faced this, or able to reproduce this with the sample app.

fornaxM commented 8 years ago

Commenting out the line - [self.webView stopLoading:nil]; in -(void)destroyWindow seems to avoid the crash.

thomasvl commented 8 years ago

https://github.com/google/gtm-oauth2/commit/ce661d47f02a6d57a6e5dd981d7880cf2f5ccd18 likely fixed this.

fornaxM commented 8 years ago

Awesome. Will update. 👍 @thomasvl

sera8705 commented 5 years ago

This is the last few lines of code on a different thread that I can see while I debug the issue. I've spent quite some time on debugging this now with no success and eventually decided to file this issue.

Thread 31Queue : com.apple.NSURLSession-work (serial)

0 0x00007fff8a4b50f0 in CFBasicHashAddValue () #1 0x00007fff8a4b667d in CFDictionarySetValue () #2 0x00007fff94df3351 in HTTPHeaderDict::setValue(HTTPHeaderKeyMixedValue const&, HTTPHeaderValueMixedValue const&) () #3 0x00007fff94e1b083 in HTTPMessage::setHeaderFieldScalarValue(CFNetworkConstantString::HTTPHeader::DomainString, long long) () #4 0x00007fff94e1af63 in URLRequest::setHTTPBodyParts(CFArray const_) () #5 0x00007fff94df4d3d in -NSURLSessionLocal _onqueue_connectUploadTask:strippedRequest:bodyStream:bodyParts: #6 0x00007fff94df3f56 in -NSCFLocalSessionTask _onqueue_completeInitialization #7 0x00007fff94df3df8 in 30-[NSCFURLSessionTask resume]_block_invoke () #8 0x0000000100097070 in _dispatch_call_block_and_release () #9 0x0000000100089cc5 in _dispatch_client_callout () #10 0x000000010008f112 in _dispatch_queue_drain () #11 0x0000000100096e24 in _dispatch_queue_invoke () #12 0x000000010008ddab in _dispatch_root_queue_drain () #13 0x000000010008d8a5 in _dispatch_worker_thread3 () #14 0x00000001000ec336 in _pthread_wqthread () #15 0x00000001000e9f91 in start_wqthread () Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial) #0 0x000000010008ccb7 in _dispatch_barrier_async_f_slow () #1 0x00007fff94df3d33 in -NSCFURLSessionTask resume #2 0x0000000100013117 in -[GTMSessionFetcher beginFetchMayDelay:mayAuthorize:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:797 #3 0x000000010000ef4c in -[GTMSessionFetcher beginFetchWithCompletionHandler:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:327 #4 0x000000010000fdc4 in -[GTMSessionFetcher beginFetchWithDelegate:didFinishSelector:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMSessionFetcher.m:354 #5 0x0000000100004b78 in -[GTMOAuth2Authentication beginTokenFetchWithDelegate:didFinishSelector:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2Authentication.m:858 #6 0x0000000100009637 in -[GTMOAuth2SignIn authCodeObtained] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2SignIn.m:524 #7 0x0000000100009202 in -[GTMOAuth2SignIn requestRedirectedToRequest:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2SignIn.m:428 #8 0x000000010000cbc5 in -[GTMOAuth2WindowController webView:resource:willSendRequest:redirectResponse:fromDataSource:] at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/gtm-oauth/GTMOAuth2WindowController.m:473 #9 0x00007fff935f6723 in CallResourceLoadDelegate(void ()(), WebView, objcselector, objcobject, objcobject, objcobject, objcobject) () #10 0x00007fff9358456d in WebFrameLoaderClient::dispatchWillSendRequest(WebCore::DocumentLoader, unsigned long, WebCore::ResourceRequest&, WebCore::ResourceResponse const&) () #11 0x00007fff827674ec in WebCore::ResourceLoadNotifier::dispatchWillSendRequest(WebCore::DocumentLoader, unsigned long, WebCore::ResourceRequest&, WebCore::ResourceResponse const&) () #12 0x00007fff833c6c5c in WebCore::ResourceLoader::willSendRequestInternal(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) () #13 0x00007fff834d64c8 in WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) () #14 0x00007fff8276ae5c in WebCore::ResourceHandle::willSendRequest(WebCore::ResourceRequest&, WebCore::ResourceResponse const&) () #15 0x00007fff82769c46 in -WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse: #16 0x00007fff94e11c01 in _ZL31_NSURLConnectionWillSendRequestP16_CFURLConnectionPK13_CFURLRequestP14_CFURLResponsePKv_block_invoke () #17 0x00007fff94e11b49 in 65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke () #18 0x00007fff94e11a5e in -NSURLConnectionInternal _withConnectionAndDelegate:onlyActive: #19 0x00007fff94e11963 in -NSURLConnectionInternal _withActiveConnectionAndDelegate: #20 0x00007fff94e118fa in _NSURLConnectionWillSendRequest(CFURLConnection, CFURLRequest const, CFURLResponse, void const_) () #21 0x00007fff94fabcd1 in ___ZN27URLConnectionClient_Classic39_delegate_willSendRequestForRedirectionEPK12NSURLRequestP14_CFURLResponseU13block_pointerFvS2_E_blockinvoke () #22 0x00007fff94fab519 in ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 () #23 0x0000000100089cc5 in _dispatch_client_callout () #24 0x0000000100099e08 in _dispatch_block_invoke () #25 0x00007fff94e11820 in RunloopBlockContext::_invokeblock(void const, void_) () #26 0x00007fff8a4f7d74 in CFArrayApplyFunction () #27 0x00007fff94e11719 in RunloopBlockContext::perform() () #28 0x00007fff94e115ba in MultiplexerSource::perform() () #29 0x00007fff94e113dc in MultiplexerSource::perform(void) () #30 0x00007fff8a555881 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORMFUNCTION* ()

31 0x00007fff8a534fbc in __CFRunLoopDoSources0 ()

32 0x00007fff8a5344df in __CFRunLoopRun ()

33 0x00007fff8a533ed8 in CFRunLoopRunSpecific ()

34 0x00007fff87b56935 in RunCurrentEventLoopInMode ()

35 0x00007fff87b5676f in ReceiveNextEventCommon ()

36 0x00007fff87b565af in _BlockUntilNextEventMatchingListInModeWithFilter ()

37 0x00007fff8bbb9efa in _DPSNextEvent ()

38 0x00007fff8bbb932a in -NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:

39 0x00007fff8bbade84 in -NSApplication run

40 0x00007fff8bb7746c in NSApplicationMain ()

41 0x0000000100007612 in main at /Users/mbasaralusrinivasa/workspace/test/MyPlayground/TestApp/OAuthTest/OAuthTest/OAuthTest/main.m:12

42 0x00007fff885c75ad in start ()

I will continue to debug and post any updates. It would be great to get any pointers from anyone else who has faced this, or able to reproduce this with the sample app.