[GH-ISSUE #433] Crash of '[unowned self] #281

Closed
opened 2026-03-03 16:47:21 +03:00 by kerem · 1 comment
Owner

Originally created by @clarkjk on GitHub (Feb 6, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/433

Description:

This appears to be related to a previous issue #276 that now exist in this new version of the code. The requestOAuthAccessToken uses [unowned self]. I suggest to use [weak self] here.

Here is my crash log:

#0. Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x181e542e8 __pthread_kill + 8
1  libsystem_pthread.dylib        0x181f692f8 pthread_kill$VARIANT$mp + 396
2  libsystem_c.dylib              0x181dc2fbc abort + 140
3  libswiftCore.dylib             0x105ae4ef8 swift_vasprintf(char**, char const*, char*) + 54
4  libswiftCore.dylib             0x105ae5000 swift::swift_abortRetainUnowned(void const*) + 32
5  libswiftCore.dylib             0x105b12c24 swift_unknownUnownedTakeStrong + 74
6  OAuthSwift                     0x10570913c specialized closure #1 in OAuth2Swift.requestOAuthAccessToken(withParameters:headers:success:failure:) (OAuth2Swift.swift:211)
7  OAuthSwift                     0x10570a150 partial apply for closure #1 in OAuth2Swift.requestOAuthAccessToken(withParameters:headers:success:failure:) (OAuth2Swift.swift)
8  OAuthSwift                     0x105722f18 specialized closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift:167)
9  OAuthSwift                     0x10571ce90 closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift)
10 OAuthSwift                     0x105722664 partial apply for closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift)
11 OAuthSwift                     0x10571cf90 thunk for @callee_owned (@owned Data?, @owned URLResponse?, @owned Error?) -> () (OAuthSwiftHTTPRequest.swift)
12 CFNetwork                      0x1828cd38c __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 32
13 CFNetwork                      0x1828e5ce0 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 152
14 Foundation                     0x182d19ba0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
15 Foundation                     0x182c59894 -[NSBlockOperation main] + 72
16 Foundation                     0x182c494c4 -[__NSOperationInternal _start:] + 848
17 libdispatch.dylib              0x181cbea14 _dispatch_client_callout + 16
18 libdispatch.dylib              0x181cc6200 _dispatch_block_invoke_direct$VARIANT$mp + 288
19 libdispatch.dylib              0x181cbea14 _dispatch_client_callout + 16
20 libdispatch.dylib              0x181cc6200 _dispatch_block_invoke_direct$VARIANT$mp + 288
21 libdispatch.dylib              0x181cc60ac dispatch_block_perform$VARIANT$mp + 104
22 Foundation                     0x182d1b878 __NSOQSchedule_f + 376
23 libdispatch.dylib              0x181cbea14 _dispatch_client_callout + 16
24 libdispatch.dylib              0x181ccb698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016
25 CoreFoundation                 0x1822ea544 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
26 CoreFoundation                 0x1822e8120 __CFRunLoopRun + 2012
27 CoreFoundation                 0x182207e58 CFRunLoopRunSpecific + 436
28 GraphicsServices               0x1840b4f84 GSEventRunModal + 100
29 UIKit                          0x18b95c67c UIApplicationMain + 236
30 CGM-Enterprise                 0x105037a10 main (main.m:20)
31 libdyld.dylib                  0x181d2456c start + 4

OAuth Provider (Twitter, Github, ..):

Self Provider

OAuth Version:

  • Version 1
  • [x ] Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • [x ] CocoaPods
  • Manually

Library version:

  • head
  • [ x] v1.2 (Swift 4.0)
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

Xcode version:

  • [x ] 9.0 (Swift 4.0)

  • 9.0 (Swift 3.2)

  • 8.x (Swift 3.x)

  • 8.0 (Swift 2.3)

  • 7.3.1

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @clarkjk on GitHub (Feb 6, 2018). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/433 ### Description: This appears to be related to a previous issue #276 that now exist in this new version of the code. The requestOAuthAccessToken uses [unowned self]. I suggest to use [weak self] here. Here is my crash log: ``` #0. Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0x181e542e8 __pthread_kill + 8 1 libsystem_pthread.dylib 0x181f692f8 pthread_kill$VARIANT$mp + 396 2 libsystem_c.dylib 0x181dc2fbc abort + 140 3 libswiftCore.dylib 0x105ae4ef8 swift_vasprintf(char**, char const*, char*) + 54 4 libswiftCore.dylib 0x105ae5000 swift::swift_abortRetainUnowned(void const*) + 32 5 libswiftCore.dylib 0x105b12c24 swift_unknownUnownedTakeStrong + 74 6 OAuthSwift 0x10570913c specialized closure #1 in OAuth2Swift.requestOAuthAccessToken(withParameters:headers:success:failure:) (OAuth2Swift.swift:211) 7 OAuthSwift 0x10570a150 partial apply for closure #1 in OAuth2Swift.requestOAuthAccessToken(withParameters:headers:success:failure:) (OAuth2Swift.swift) 8 OAuthSwift 0x105722f18 specialized closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift:167) 9 OAuthSwift 0x10571ce90 closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift) 10 OAuthSwift 0x105722664 partial apply for closure #1 in closure #1 in OAuthSwiftHTTPRequest.start(success:failure:) (OAuthSwiftHTTPRequest.swift) 11 OAuthSwift 0x10571cf90 thunk for @callee_owned (@owned Data?, @owned URLResponse?, @owned Error?) -> () (OAuthSwiftHTTPRequest.swift) 12 CFNetwork 0x1828cd38c __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 32 13 CFNetwork 0x1828e5ce0 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 152 14 Foundation 0x182d19ba0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16 15 Foundation 0x182c59894 -[NSBlockOperation main] + 72 16 Foundation 0x182c494c4 -[__NSOperationInternal _start:] + 848 17 libdispatch.dylib 0x181cbea14 _dispatch_client_callout + 16 18 libdispatch.dylib 0x181cc6200 _dispatch_block_invoke_direct$VARIANT$mp + 288 19 libdispatch.dylib 0x181cbea14 _dispatch_client_callout + 16 20 libdispatch.dylib 0x181cc6200 _dispatch_block_invoke_direct$VARIANT$mp + 288 21 libdispatch.dylib 0x181cc60ac dispatch_block_perform$VARIANT$mp + 104 22 Foundation 0x182d1b878 __NSOQSchedule_f + 376 23 libdispatch.dylib 0x181cbea14 _dispatch_client_callout + 16 24 libdispatch.dylib 0x181ccb698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016 25 CoreFoundation 0x1822ea544 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 26 CoreFoundation 0x1822e8120 __CFRunLoopRun + 2012 27 CoreFoundation 0x182207e58 CFRunLoopRunSpecific + 436 28 GraphicsServices 0x1840b4f84 GSEventRunModal + 100 29 UIKit 0x18b95c67c UIApplicationMain + 236 30 CGM-Enterprise 0x105037a10 main (main.m:20) 31 libdyld.dylib 0x181d2456c start + 4 ``` ### OAuth Provider (Twitter, Github, ..): Self Provider ### OAuth Version: - [ ] Version 1 - [x ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x ] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ x] v1.2 (Swift 4.0) - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x ] 9.0 (Swift 4.0) - [ ] 9.0 (Swift 3.2) - [ ] 8.x (Swift 3.x) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:47:21 +03:00
Author
Owner

@phimage commented on GitHub (Feb 6, 2018):

retain error will be send to failure callback in this case instead of crashing

thanks for the report

<!-- gh-comment-id:363363841 --> @phimage commented on GitHub (Feb 6, 2018): `retain` error will be send to failure callback in this case instead of crashing thanks for the report
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#281
No description provided.