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

Force unwrap crash in Bot.init (JSON contains an error) #274

Closed
reststop opened this issue May 19, 2016 · 4 comments
Closed

Force unwrap crash in Bot.init (JSON contains an error) #274

reststop opened this issue May 19, 2016 · 4 comments
Labels

Comments

@reststop
Copy link

reststop commented May 19, 2016

@ BuildaUtils/JSON.swift:: L#74

73    public func nonOptionalForKey(key: String) -> Z {
74        return self.optionalForKey(key)!
75    }

Context parameters::

Key = "configuration"
self = 2 key/value pairs
   key = NSTaggedPointerString*
   value = "error creating bot: Could not perform request because the database produced an error: error happened in your connection"
   key = NSTaggedPointerString*
   value = Int64(500)

Stack Trace::

fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb) bt
* thread #1: tid = 0x32c45c6, 0x000000010101b728 libswiftCore.dylib`function signature specialization  of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 40, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000010101b728 libswiftCore.dylib`function signature specialization  of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 40
  * frame #1: 0x0000000100490310 BuildaUtils`NSDictionary.nonOptionalForKey (key="configuration", self=2 key/value pairs) -> A + 704 at JSON.swift:74
    frame #2: 0x0000000100490df4 BuildaUtils`NSDictionary.dictionaryForKey(key="configuration", self=2 key/value pairs) -> NSDictionary + 84 at JSON.swift:121
    frame #3: 0x0000000100490e58 BuildaUtils`@objc NSDictionary.dictionaryForKey(String) -> NSDictionary + 72 at JSON.swift:0
    frame #4: 0x0000000100a418d3 XcodeServerSDK`Bot.init(json=2 key/value pairs) -> Bot + 227 at Bot.swift:20
    frame #5: 0x0000000100a41797 XcodeServerSDK`Bot.__allocating_init(json : NSDictionary) -> Bot + 55 at Bot.swift:0
    frame #6: 0x0000000100a87913 XcodeServerSDK`XcodeServer.(response=0x0000600000023b20, body=Some, error=nil, completion=0x0000000100bd0b50 BuildaKit`partial apply forwarder for static BuildaKit.XcodeServerSyncerUtils.(createBotFromBuildTemplate (Swift.String, syncer : BuildaKit.StandardSyncer, template : BuildaKit.BuildTemplate, project : BuildaKit.Project, branch : Swift.String, scheduleOverride : Swift.Optional, xcodeServer : XcodeServerSDK.XcodeServer, completion : (bot : Swift.Optional, error : Swift.Optional<__ObjC.NSError>) -> ()) -> ()).(closure #1) at XcodeServerSyncerUtils.swift)(Bot, completion : (response : XcodeServer.CreateBotResponse) -> ()) -> ()).(closure #1) + 451 at XcodeServer+Bot.swift:208
    frame #7: 0x0000000100a99ec8 XcodeServerSDK`XcodeServer.(response=0x0000600000023b20, body=Some, error=nil, completion=0x0000000100a85820 XcodeServerSDK`partial apply forwarder for XcodeServerSDK.XcodeServer.((createBotNoValidation in _C0122213F3E9259288EB5FBCD97EEB0B) (XcodeServerSDK.Bot, completion : (response : XcodeServerSDK.XcodeServer.CreateBotResponse) -> ()) -> ()).(closure #1) at XcodeServer+Bot.swift, self=0x0000608000140790) -> ()) -> NSURLSessionTask?).(closure #1) + 1848 at XcodeServer.swift:145
    frame #8: 0x000000010048d83b BuildaUtils`HTTP.(data=146 bytes, response=0x0000600000023b20, error=nil, completion=0x0000000100a99330 XcodeServerSDK`partial apply forwarder for XcodeServerSDK.XcodeServer.(sendRequestWithMethod (BuildaUtils.HTTP.Method, endpoint : XcodeServerSDK.XcodeServerEndpoints.Endpoint, params : Swift.Optional>, query : Swift.Optional>, body : Swift.Optional<__ObjC.NSDictionary>, portOverride : Swift.Optional, completion : (response : Swift.Optional<__ObjC.NSHTTPURLResponse>, body : Swift.Optional, error : Swift.Optional<__ObjC.NSError>) -> ()) -> Swift.Optional<__ObjC.NSURLSessionTask>).(closure #1) at XcodeServer.swift) -> ()) -> NSURLSessionTask).(closure #1) + 2507 at HTTPUtils.swift:63
    frame #9: 0x000000010048e187 BuildaUtils`thunk + 103 at HTTPUtils.swift:0
    frame #10: 0x00007fff89d3e7f1 CFNetwork`__75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 21
    frame #11: 0x00007fff89d3e0bf CFNetwork`__49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 302
    frame #12: 0x00007fff99d207d7 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
    frame #13: 0x00007fff99d20495 Foundation`-[NSBlockOperation main] + 100
    frame #14: 0x00007fff99d1eb7a Foundation`-[__NSOperationInternal _start:] + 654
    frame #15: 0x00007fff99d1ab64 Foundation`__NSOQSchedule_f + 194
    frame #16: 0x0000000101412cc5 libdispatch.dylib`_dispatch_client_callout + 8
    frame #17: 0x000000010142a6ae libdispatch.dylib`_dispatch_main_queue_callback_4CF + 2845
    frame #18: 0x00007fff884a29e9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    frame #19: 0x00007fff884618dd CoreFoundation`__CFRunLoopRun + 1949
    frame #20: 0x00007fff88460ed8 CoreFoundation`CFRunLoopRunSpecific + 296
    frame #21: 0x00007fff87dd8935 HIToolbox`RunCurrentEventLoopInMode + 235
    frame #22: 0x00007fff87dd876f HIToolbox`ReceiveNextEventCommon + 432
    frame #23: 0x00007fff87dd85af HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #24: 0x00007fff99012efa AppKit`_DPSNextEvent + 1067
    frame #25: 0x00007fff9901232a AppKit`-[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    frame #26: 0x00007fff99006e84 AppKit`-[NSApplication run] + 682
    frame #27: 0x00007fff98fd046c AppKit`NSApplicationMain + 1176
    frame #28: 0x0000000100104504 Buildasaur`main + 84 at AppDelegate.swift:25
    frame #29: 0x00007fff8d9415ad libdyld.dylib`start + 1
    frame #30: 0x00007fff8d9415ad libdyld.dylib`start + 1
@czechboy0
Copy link
Member

Interesting, this looks like a genuine error in XcodeServerSDK. Could you please provide more details on the response that you received? The error code? The JSON contents? It looks like we got 200 OK, with a JSON payload, but the contents were an error instead of Bot contents. So I need as much info as possible to be able to detect this earlier in the call, thanks! 😊

@czechboy0 czechboy0 added the bug label May 20, 2016
@czechboy0 czechboy0 changed the title fatal error: unexpectedly found nil while unwrapping an Optional value Force unwrap crash in Bot.init (JSON contains an error) May 20, 2016
@reststop
Copy link
Author

If the crash re-occurs, I will definitely get more data. So far, it has not recurred.

@czechboy0
Copy link
Member

I ended up moving to error propagation with #281, so now Buildasaur shouldn't crash anymore if it can't find an expected key in a received JSON. Please report if you still see this, now it'll just be a syncer error being printed out and shown in the UI.

@reststop
Copy link
Author

Sounds good. It has only happened once so far.

On Fri, Jun 17, 2016 at 7:23 AM, Honza Dvorsky notifications@github.com
wrote:

Closed #274 #274.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#274 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARgKXKmBfASu-z23ggFixy6yeXQYMMdks5qMq3KgaJpZM4IiwKV
.

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

No branches or pull requests

2 participants