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

Phone calls can trigger immediate crash #253

Closed
cohoe opened this issue Jan 16, 2024 · 3 comments
Closed

Phone calls can trigger immediate crash #253

cohoe opened this issue Jan 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working high priority Something that really should be implemented NowTM
Milestone

Comments

@cohoe
Copy link
Member

cohoe commented Jan 16, 2024

I was trying to simulate starting a KrakenTalk phone call with a Javascript script by opening a websocket to the endpoint https://beta.twitarr.com/api/v3/phone/socket/initiate/DCB94249-4562-493D-964C-C3E733FBD5D3/to/46E2B505-FA66-4A4C-80EF-3BF5D253579F. The callID DCB94249-4562-493D-964C-C3E733FBD5D3 is a random UUID I generated. The userID 46E2B505-FA66-4A4C-80EF-3BF5D253579F is the sam user.

If Sam doesn't have a notification socket open (like if it's only logged in via the browser) then the app basically does nothing which is expected and produces the following logs:

[ INFO ] GET /api/v3/phone/socket/initiate/DCB94249-4562-493D-964C-C3E733FBD5D3/to/46E2B505-FA66-4A4C-80EF-3BF5D253579F -> 101 Switching Protocols [request-id: A73EACD1-186D-4825-B3CB-C24FC1D43EDB]
[ NOTICE ] Attempt to call user with no notification socket. [request-id: A73EACD1-186D-4825-B3CB-C24FC1D43EDB]

But if Sam is logged in via Tricordarr which opens a notification socket and the same call is made, the app immediately crashes:

[ INFO ] GET /api/v3/phone/socket/initiate/DCB94249-4562-493D-964C-C3E733FBD5D3/to/46E2B505-FA66-4A4C-80EF-3BF5D253579F -> 101 Switching Protocols [request-id: 03E58630-D14C-4AAD-A90C-BF8AC441B2DC]
[ NOTICE ] Creating phone socket. [request-id: 03E58630-D14C-4AAD-A90C-BF8AC441B2DC]
[ NOTICE ] Sending incoming phonecall to callee. [request-id: 03E58630-D14C-4AAD-A90C-BF8AC441B2DC]
[ NOTICE ] Sending incoming phonecall to callee. [request-id: 03E58630-D14C-4AAD-A90C-BF8AC441B2DC]
Received signal 4. Backtrace:
[ INFO ] GET /api/v3/notification/global -> 200 OK [request-id: 50B32616-134E-4603-A527-8E104788A120]
0x55c43126bdf2, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /app/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:80
0x55c43126c067, closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array<Swift.Int32>) -> () at /app/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:94
0x55c43126c067, @objc closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array<Swift.Int32>) -> () at /app/<compiler-generated>:93
0x7fd2dc75751f
0x55c431c76310, Swift runtime failure: precondition failure at /app/<compiler-generated>:0
0x55c431c76310, function signature specialization <Arg[0] = Dead, Arg[1] = Dead> of (extension in NIOCore):NIOCore.EventLoop.preconditionInEventLoop(file: Swift.StaticString, line: Swift.UInt) -> () at /app/<compiler-generated>:0
0x55c431c76310, (extension in NIOCore):NIOCore.EventLoop.preconditionInEventLoop(file: Swift.StaticString, line: Swift.UInt) -> () at /app/<compiler-generated>:0
0x55c431c76310, generic specialization <@Sendable (WebSocketKit.WebSocket, NIOCore.ByteBuffer) -> ()> of NIOCore.NIOLoopBoundBox.value.setter : A at /app/<compiler-generated>:0
0x55c431c76310, WebSocketKit.WebSocket.onBinary((WebSocketKit.WebSocket, NIOCore.ByteBuffer) -> ()) -> () at /app/.build/checkouts/websocket-kit/Sources/WebSocketKit/WebSocket.swift:66
0x55c431e1bf81, (4) suspend resume partial function for swiftarr.PhonecallController.createPhoneSocket(Vapor.Request, WebSocketKit.WebSocket) async -> () at /app/Sources/swiftarr/Controllers/PhonecallController.swift:274
0x7fd2dd2a50cd
0x7fd2dd2a589b
0x7fd2ddde6773
0x7fd2ddde6521
0x7fd2dddf2001
0x7fd2dc7a9ac2
0x7fd2dc83a813
0xffffffffffffffff

The Android app reported a socket message came through matching what we expect, so whatever issue here is happening immediately after the call notification goes through.

I was able to reproduce this in the Beta, my personal instance, and locally. Analyzing the coredump yields:

* thread #1, name = 'swiftarr', stop reason = signal SIGILL: illegal operand
  * frame #0: 0x000056135ea49310 swiftarr`$s12WebSocketKit0aB0C8onBinaryyyyAC_7NIOCore10ByteBufferVtcF at <compiler-generated>:0
    frame #1: 0x000056135ebeef82 swiftarr`$s8swiftarr19PhonecallControllerV17createPhoneSocketyy5Vapor7RequestC_03WebF3Kit0iF0CtYaFTY3_ at PhonecallController.swift:274:6
    frame #2: 0x00007f321b3900ce
@cohoe cohoe added bug Something isn't working high priority Something that really should be implemented NowTM labels Jan 16, 2024
@cohoe
Copy link
Member Author

cohoe commented Jan 16, 2024

I thought maybe this was being triggered by having multiple NotificationSockets open. But it still died even when I had only one (logged the calleeNotificationSockets.count to be sure).

@cohoe
Copy link
Member Author

cohoe commented Jan 16, 2024

Oh. Pretty sure it's vapor/websocket-kit#140

@cohoe
Copy link
Member Author

cohoe commented Jan 16, 2024

Workaround described in vapor/websocket-kit#140 seems to be functioning!

cohoe added a commit to cohoe/swiftarr that referenced this issue Jan 16, 2024
cohoe added a commit to cohoe/swiftarr that referenced this issue Jan 16, 2024
cohoe added a commit to cohoe/swiftarr that referenced this issue Jan 18, 2024
cohoe added a commit to cohoe/swiftarr that referenced this issue Jan 18, 2024
@cohoe cohoe self-assigned this Jan 18, 2024
@cohoe cohoe added this to the 2024 Sailing milestone Jan 18, 2024
@cohoe cohoe closed this as completed in 435d448 Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Something that really should be implemented NowTM
Projects
None yet
Development

No branches or pull requests

1 participant