blinksh / blink

Blink Mobile Shell for iOS (Mosh based)
https://blink.sh
GNU General Public License v3.0
6.08k stars 565 forks source link

mosh to host with ProxyJump throws Fatal error: Unexpectedly found nil while unwrapping an Optional value #1969

Closed l2dy closed 6 days ago

l2dy commented 4 months ago

Checklist

Configuration

Blink version: commit df04676bc07fde94b57a9cc7aedf2430ab996e07 iOS version: 17.3.1

Describe the bug

Execute mosh <host>, where <host> is configured with a ProxyJump bastion.

Expected behavior: Blink app should not crash.

https://github.com/blinksh/blink/blob/df04676bc07fde94b57a9cc7aedf2430ab996e07/SSH/SSHClient.swift#L279

* thread #15, stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
    frame #0: 0x00007ff815081110 libswiftCore.dylib`_swift_runtime_on_report
    frame #1: 0x00007ff81513560e libswiftCore.dylib`_swift_stdlib_reportFatalErrorInFile + 222
    frame #2: 0x00007ff814d9ef9a libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 314
    frame #3: 0x00007ff814d9ee1e libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 366
    frame #4: 0x00007ff814d9eb5b libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 123
    frame #5: 0x00007ff814d9e816 libswiftCore.dylib`Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 230
  * frame #6: 0x0000000108f82bb9 SSH`closure #2 in SSHClient.setupCallbacks(cmd=0x600000311c00, inSock=21, outSock=21, userdata=0x10ac31e20) at SSHClient.swift:279:28
    frame #7: 0x0000000108f82c29 SSH`@objc closure #2 in SSHClient.setupCallbacks() at <compiler-generated>:0
    frame #8: 0x000000010900b154 SSH`ssh_socket_connect_proxycommand + 244
    frame #9: 0x0000000108fc9677 SSH`ssh_connect + 695
    frame #10: 0x0000000108f876c2 SSH`closure #2 in SSHClient.connect(session=0x000000010e052000, timerFired=false, self=0x000000010ac31e20, timer=0x0000600003723600) at SSHClient.swift:490:18
    frame #11: 0x0000000108f90ff8 SSH`partial apply for closure #2 in SSHClient.connect() at <compiler-generated>:0
    frame #12: 0x0000000108f48b46 SSH`closure #1 in Publisher.tryOperation<τ_0_0, τ_0_1>(p=0x000000010e052000, doTry=true, operation=0x108f90fe0) at Publishers.swift:52:22
    frame #13: 0x0000000108f48fcb SSH`partial apply for closure #1 in Publisher.tryOperation<τ_0_0, τ_0_1>(_:) at <compiler-generated>:0
    frame #14: 0x00007ff83785bd2d Combine`Combine.Publishers.TryMap.Inner.receive(τ_0_0.Output) -> Combine.Subscribers.Demand + 157
    frame #15: 0x00007ff83785c440 Combine`protocol witness for Combine.Subscriber.receive(τ_0_0.Input) -> Combine.Subscribers.Demand in conformance Combine.Publishers.TryMap<τ_0_0, τ_0_1>.Inner<τ_1_0> : Combine.Subscriber in Combine + 16
    frame #16: 0x00007ff83785b546 Combine`Combine.Publishers.Map.Inner.receive(τ_0_0.Output) -> Combine.Subscribers.Demand + 86
    frame #17: 0x00007ff8377e3fe3 Combine`Combine.Publishers.Print.Inner.receive(τ_0_0.Output) -> Combine.Subscribers.Demand + 931
    frame #18: 0x00007ff8377e4b20 Combine`protocol witness for Combine.Subscriber.receive(τ_0_0.Input) -> Combine.Subscribers.Demand in conformance Combine.Publishers.Print<τ_0_0>.Inner<τ_1_0> : Combine.Subscriber in Combine + 16
    frame #19: 0x00007ff8377ba597 Combine`Combine.Publishers.SubscribeOn.Inner.receive(τ_0_0.Output) -> Combine.Subscribers.Demand + 135
    frame #20: 0x00007ff8377ba6d0 Combine`protocol witness for Combine.Subscriber.receive(τ_0_0.Input) -> Combine.Subscribers.Demand in conformance Combine.Publishers.SubscribeOn<τ_0_0, τ_0_1>.Inner<τ_1_0> : Combine.Subscriber in Combine + 16
    frame #21: 0x00007ff8377e3fe3 Combine`Combine.Publishers.Print.Inner.receive(τ_0_0.Output) -> Combine.Subscribers.Demand + 931
    frame #22: 0x00007ff8377e4b20 Combine`protocol witness for Combine.Subscriber.receive(τ_0_0.Input) -> Combine.Subscribers.Demand in conformance Combine.Publishers.Print<τ_0_0>.Inner<τ_1_0> : Combine.Subscriber in Combine + 16
    frame #23: 0x00007ff837829ce5 Combine`Swift.Result.Publisher.Inner.request(Combine.Subscribers.Demand) -> () + 469
    frame #24: 0x00007ff837829dc0 Combine`protocol witness for Combine.Subscription.request(Combine.Subscribers.Demand) -> () in conformance Swift.Result<τ_0_0, τ_0_1>.Publisher.Inner<τ_1_0> : Combine.Subscription in Combine + 16
    frame #25: 0x00007ff8377e4729 Combine`Combine.Publishers.Print.Inner.request(Combine.Subscribers.Demand) -> () + 953
    frame #26: 0x00007ff8377e4b60 Combine`protocol witness for Combine.Subscription.request(Combine.Subscribers.Demand) -> () in conformance Combine.Publishers.Print<τ_0_0>.Inner<τ_1_0> : Combine.Subscription in Combine + 16
    frame #27: 0x00007ff8377ba057 Combine`closure #1 () -> () in Combine.Publishers.SubscribeOn.Inner.request(Combine.Subscribers.Demand) -> () + 119
    frame #28: 0x00007ff8377bb847 Combine`partial apply forwarder for closure #1 () -> () in Combine.Publishers.SubscribeOn.Inner.request(Combine.Subscribers.Demand) -> () + 55
    frame #29: 0x00007ff800864c39 Foundation`reabstraction thunk helper from @escaping @callee_guaranteed @Sendable () -> () to @escaping @callee_unowned @convention(block) @Sendable () -> () + 25
    frame #30: 0x00007ff8003f807a CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #31: 0x00007ff8003f782d CoreFoundation`__CFRunLoopDoBlocks + 391
    frame #32: 0x00007ff8003f25ea CoreFoundation`__CFRunLoopRun + 2186
    frame #33: 0x00007ff8003f197d CoreFoundation`CFRunLoopRunSpecific + 557
    frame #34: 0x00007ff8003f2968 CoreFoundation`CFRunLoopRun + 40
    frame #35: 0x0000000105b1a583 Blink`awaitRunLoop(runLoop=0x00006000017c4280) at Helpers.swift:101:3
    frame #36: 0x0000000105a32b0b Blink`BlinkMosh.startMoshServer(command=Blink.MoshCommand @ 0x0000700010456da0, self=0x000000010aa0f4d0) at mosh.swift:216:7
    frame #37: 0x0000000105a30c2a Blink`BlinkMosh.main(argc=2, argv=0x6000002e3c40, self=0x000000010aa0f4d0) at mosh.swift:130:26
    frame #38: 0x0000000105a311fd Blink`@objc BlinkMosh.main(_:argv:) at <compiler-generated>:0
    frame #39: 0x00000001059c66a4 Blink`-[Session _run](self=0x000000010aa0f4d0, _cmd="_run") at Session.m:163:3
    frame #40: 0x00000001059c661f Blink`run_session(sessionData=0x000000010aa0f4d0) at Session.m:149:3
    frame #41: 0x0000000108788202 libsystem_pthread.dylib`_pthread_start + 99
    frame #42: 0x0000000108783bab libsystem_pthread.dylib`thread_start + 15
carloscabanero commented 4 months ago

Found the issue here. Is not ProxyCommand itself but the new mosh implementation. Fixing.