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

Version 2.60.0 causing app to crash when launched on iOS 15.5 simulator #2574

Closed
MatthewTHFisher opened this issue Oct 25, 2023 · 26 comments
Closed

Comments

@MatthewTHFisher
Copy link

MatthewTHFisher commented Oct 25, 2023

Expected behavior

When running our iOS app on an iOS 15.5 simulator with the swift-nio package version 2.60.0, our app launches and runs as expected.

Actual behavior

When running on a iOS 15.5 simulator while using swift-nio 2.60.0, the app launches and then immediately crashes with Thread 1: signal SIGABRT

When run on a iOS 16.4 simulator the app runs as expected.

Workaround

Downgrade to swift-nio version 2.59.0 and the app runs fine on iOS 15.5 simulators.

System & version information

OS System - MacOS 13.6 (22G120)
Processer type - Attempted on both Intel and Apple-silicon
Xcode - 14.3.1 (14E300c)
Xcode simulators - iPhone 12 | iOS 15.5 & iOS 16.4

@dnadoba
Copy link
Member

dnadoba commented Oct 25, 2023

Could you provide us with a crash report? Here is some information how to gather crash reports.

@MatthewTHFisher
Copy link
Author

Here is a crash report from one of the sessions APP_NAME-2023-10-25-133231.txt

@dnadoba
Copy link
Member

dnadoba commented Oct 25, 2023

hm... this doesn't include a backtrace/stacktrace. Do you have this as well? The crashing thread is the most important thing but from the other running threads would be good as well. Preferably symbolicated.

@weissi
Copy link
Member

weissi commented Oct 25, 2023

@dnadoba this has a stack trace

Incident Identifier: 1086025F-7F64-42EC-8CAF-D9724CBAB527
CrashReporter Key:   40D309A8-4B1A-C8AB-A1EF-CB71C1CC050A
Hardware Model:      MacBookPro14,3
Process:             APP_NAME [82754]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/2EF156A4-64B6-40FC-AC71-03A0E58CE698/data/Containers/Bundle/Application/0A73DFE0-D246-4BB8-AFC9-1D6ED0F5AA61/APP_NAME.app/APP_NAME
Identifier:          com.APP_NAME.app
Version:             1.0 (1)
Code Type:           X86-64 (Native)
Role:                Foreground
Parent Process:      Exited process [82767]
Coalition:           com.apple.CoreSimulator.SimDevice.2EF156A4-64B6-40FC-AC71-03A0E58CE698 [3117]
Responsible Process: SimulatorTrampoline [6243]

Date/Time:           2023-10-25 13:32:11.6325 +0100
Launch Time:         2023-10-25 13:31:53.8895 +0100
OS Version:          macOS 13.6 (22G120)
Release Type:        User
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Thread 0 Crashed:
0   dyld                          	       0x11646ac52 __abort_with_payload + 10
1   dyld                          	       0x116484fd7 abort_with_payload_wrapper_internal + 82
2   dyld                          	       0x116485009 abort_with_payload + 9
3   dyld_sim                      	       0x10aa9f8eb abort_with_payload + 26
4   dyld_sim                      	       0x10aa5f4eb dyld4::halt(char const*) + 375
5   dyld_sim                      	       0x10aa5bc1c dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3070
6   dyld_sim                      	       0x10aa5be42 _dyld_sim_prepare + 379
7   dyld                          	       0x116407424 dyld4::prepareSim(dyld4::RuntimeState&, char const*) + 1490
8   dyld                          	       0x116405abc dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 249
9   dyld                          	       0x1164053bd start + 1805


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000002000209  rbx: 0x0000000000000000  rcx: 0x00007ff7bbfd5518  rdx: 0x00007ff7bbfd5990
  rdi: 0x0000000000000006  rsi: 0x0000000000000004  rbp: 0x00007ff7bbfd5560  rsp: 0x00007ff7bbfd5518
   r8: 0x00007ff7bbfd5590   r9: 0x0000000000000000  r10: 0x0000000000000184  r11: 0x0000000000000246
  r12: 0x0000000000000184  r13: 0x00007ff7bbfd5990  r14: 0x0000000000000004  r15: 0x0000000000000006
  rip: 0x000000011646ac52  rfl: 0x0000000000000246  cr2: 0x0000000116484f85
  
Logical CPU:     0
Error Code:      0x02000209 
Trap Number:     133


Binary Images:
       0x1163ff000 -        0x11649afff dyld (*) <3df96f32-b9c9-3566-a6b7-4daebc6d6563> /usr/lib/dyld
       0x10aa5a000 -        0x10aaa7fff dyld_sim (*) <7276a69b-e3b9-3f23-957f-061350a501b4> /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
       0x103f25000 -        0x105a8cfff com.APP_NAME.app (1.0) <36759cd9-8a20-3153-9489-5dc59fd4fddf> /Users/USER/Library/Developer/CoreSimulator/Devices/2EF156A4-64B6-40FC-AC71-03A0E58CE698/data/Containers/Bundle/Application/0A73DFE0-D246-4BB8-AFC9-1D6ED0F5AA61/APP_NAME.app/APP_NAME
[...]

Error Formulating Crash Report:
dyld_process_snapshot_get_shared_cache failed

EOF

but it seems to be crashing in dyld. @MatthewTHFisher this seems unrelated to SwiftNIO, it's crashing in dyld before your binary could be loaded. Can you try again? Maybe with a clean build?

@MatthewTHFisher
Copy link
Author

MatthewTHFisher commented Oct 25, 2023

After performing a clean build the issue still persists. I also get this output in Xcode

dyld[97022]: Symbol not found: _swift_getExtendedExistentialTypeMetadata
  Referenced from: /Users/mfisher/Library/Developer/CoreSimulator/Devices/2EF156A4-64B6-40FC-AC71-03A0E58CE698/data/Containers/Bundle/Application/BA1A2580-3370-4FEB-A252-270AFE4B17E0/APP_NAME.app/APP_NAME
  Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib

@weissi
Copy link
Member

weissi commented Oct 25, 2023

After performing a clean build the issue still persists

And if you downgrade to NIO 2.59.0 it disappears?

@MatthewTHFisher
Copy link
Author

Just tried again, downgraded to NIO 2.59.0 and performed a clean build, the app runs as expected

@Lukasa
Copy link
Contributor

Lukasa commented Oct 25, 2023

@weissi do you recall if dyld in the simulator logs to the host unified log?

@weissi
Copy link
Member

weissi commented Oct 25, 2023

@weissi do you recall if dyld in the simulator logs to the host unified log?

I would very much assume so but I don't know for a fact

@MatthewTHFisher
Copy link
Author

MatthewTHFisher commented Oct 25, 2023

Just an update, I cloned the NIO package and ran the tests against an iOS 15.5 simulator (setting the packages minimum platform to iOS 15) and it crashed on me there too.

The test file is NIOHTTP1Tests/HTTPClientUpgradeTests.swift and failed at line 972 with message Thread 1: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8)

let upgraders: [any NIOTypedHTTPClientProtocolUpgrader<Bool>] = Array(clientUpgraders.map { $0 as! any NIOTypedHTTPClientProtocolUpgrader<Bool> })

I have a slight suspicion that this is related to the casting of a generic type. Maybe linked to this issue swiftlang/swift#64657

@Lukasa
Copy link
Contributor

Lukasa commented Oct 25, 2023

@MatthewTHFisher Does Console.app have dyld logs that are relevant here?

Either way, given the dyld issue I think you'll want to use Feedback Assistant to file an issue with an attached sysdiagnose. If you do this, please provide a feedback number on this issue so we can correlate.

@MatthewTHFisher
Copy link
Author

MatthewTHFisher commented Oct 26, 2023

@MatthewTHFisher Does Console.app have dyld logs that are relevant here?

Tried to look in the Console.app but couldn't spot any useful dyld logs.

I have however managed to replicate this issue on a new project within Xcode and have written the steps to reproduce this result.

  1. Create a new iOS App project in Xcode.
  2. Project > Info > Set iOS deployment target to iOS 15.0
  3. Target > General > Set minimum deployment to iOS 15.0

  4. Project > Package Dependencies > Add swift-nio package to project making sure to get version 2.60.0. When asked to choose package products choose, NIO, NIOHTTP1, and NIOWebSocket.
  5. (Optional, not sure if this mattered) Add import NIO to the list of dependencies in a file, I added it to ContentView.swift (SwiftUI).
  6. Then run the app on a iOS 15 sim.

At this point when the app launches and crashes I get the same error message in Xcode as experienced earlier (just with different project names):

After performing a clean build the issue still persists. I also get this output in Xcode

dyld[97022]: Symbol not found: _swift_getExtendedExistentialTypeMetadata
  Referenced from: /Users/mfisher/Library/Developer/CoreSimulator/Devices/2EF156A4-64B6-40FC-AC71-03A0E58CE698/data/Containers/Bundle/Application/BA1A2580-3370-4FEB-A252-270AFE4B17E0/APP_NAME.app/APP_NAME
  Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib

I have also attached the crash report here > Swift-NIO-2-60-0-Check-2023-10-26-094542.txt

To get around this issue on the above new project, try running the project with swift-nio set to 2.59.0 on an iOS 15 sim, or try running with swift-nio still set to 2.60.0 but on an iOS 16 sim.

@FranzBusch
Copy link
Member

Can you try using Xcode 15 and see if you can still reproduce this? This looks like a compiler bug where we emitted _swift_getExtendedExistentialTypeMetadata when it wasn't present for older runtimes and it looks like it was fixed some time ago already.

@MatthewTHFisher
Copy link
Author

MatthewTHFisher commented Oct 26, 2023

Can you try using Xcode 15 and see if you can still reproduce this? This looks like a compiler bug where we emitted _swift_getExtendedExistentialTypeMetadata when it wasn't present for older runtimes and it looks like it was fixed some time ago already.

Just had a colleague test this on their MacBook (M1 chip, Xcode 15.0.0) and the result was the same. The app crashed on launch with the following output.

dyld[93329]: Symbol not found: _swift_getExtendedExistentialTypeMetadata
Referenced from: /Users/NAME/Library/Developer/CoreSimulator/Devices/7CDA09D2-9CE5-4C68-9A1F-2FB91CED61E7/data/Containers/Bundle/Application/79A75945-2ADC-464F-BA20-AAF1F3722270/Swift-NIO-2-60-0-Check.app/Swift-NIO-2-60-0-Check
Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib

@FranzBusch
Copy link
Member

Thanks for all the investigation. At this point, can you please file a feedback using Apple feedback tool, attach all of the information you provided here and please send us the feedback number.

@MatthewTHFisher
Copy link
Author

MatthewTHFisher commented Oct 26, 2023

Feedback has been submitted titled "swift-nio version 2.60.0 is causing apps to crash when launched on iOS 15 simulators" and has a feedback number of FB13302639.

Edit:
In the meantime we have updated our app to use swift-nio version 2.59.0 exactly to avoid the issues with the latest version.

@dfed
Copy link

dfed commented Oct 26, 2023

I just hit this, and my crash was on device. Rolling back to 2.59.0 fixed the issue for me as well.

@chocoford
Copy link

chocoford commented Oct 27, 2023

Same problem on macOS 12.3

Termination Reason:    Namespace DYLD, Code 4 Symbol missing
Symbol not found: _swift_getExtendedExistentialTypeMetadata
Referenced from: /Applications/MyApp_Test.app/Contents/MacOS/MyApp_Test
Expected in: /usr/lib/swift/libswiftCore.dylib
(terminated at launch; ignore backtrace)

Application Specific Information:
Symbol not found: _swift_getExtendedExistentialTypeMetadata
Referenced from: /Applications/MyApp_Test.app/Contents/MacOS/MyApp_Test
Expected in: /usr/lib/swift/libswiftCore.dylib

@Lukasa
Copy link
Contributor

Lukasa commented Oct 27, 2023

Thanks git bisect: "de07e573d6fbce99cc72a558ce61dbb1ccddb205 is the first bad commit"

FranzBusch added a commit to FranzBusch/swift-nio that referenced this issue Oct 27, 2023
# Motivation
We got reports in apple#2574 that our new typed HTTP upgrader are hitting a Swift compiler bug which manifests in a runtime crash on older iOS/macOS/etc.

# Modification
This PR backs out the new typed HTTP protocol upgrader APIs so that we can unblock our users until the Swift compiler bug is fixed.

# Result
No more crashes for our users.
@FranzBusch
Copy link
Member

Thanks for all the reports. I opened a PR #2579 that backs out the new APIs that are the culprit for this crash for now. I would appreciate if @MatthewTHFisher you could re-run your test but point at my PR branch.

@MatthewTHFisher
Copy link
Author

Thanks for all the reports. I opened a PR #2579 that backs out the new APIs that are the culprit for this crash for now. I would appreciate if @MatthewTHFisher you could re-run your test but point at my PR branch.

Just tested using two methods against your branch @FranzBusch:

  • Downloaded your branch and ran the packages tests against my iOS 15.5 simulator. These all passed without any crashes.
  • Performed these steps again but with your branch, and the app runs on my iOS 15.5 simulator as expected without crashing.

Lukasa pushed a commit that referenced this issue Oct 27, 2023
# Motivation
We got reports in #2574 that our new typed HTTP upgrader are hitting a Swift compiler bug which manifests in a runtime crash on older iOS/macOS/etc.

# Modification
This PR backs out the new typed HTTP protocol upgrader APIs so that we can unblock our users until the Swift compiler bug is fixed.

# Result
No more crashes for our users.
@FranzBusch
Copy link
Member

We just released a new version that backs out the new API: https://github.com/apple/swift-nio/releases/tag/2.61.0. Please confirm that this fixes the crash

@dfed
Copy link

dfed commented Oct 27, 2023

Confirmed that 2.61.0 does not cause a crash on my iOS 15 device.

@Kyle-Ye
Copy link

Kyle-Ye commented Nov 2, 2023

This is recently fixed upstream by swiftlang/swift#69475 on Swift 5.10.

@ashgti
Copy link
Contributor

ashgti commented Nov 2, 2023

With this issue closed, should is the NIOWebSocketServer unblocked (see https://github.com/apple/swift-nio/blob/main/Sources/NIOWebSocketServer/Server.swift#L51) or is there additional work that need to be done to enable the WebSocketServer example code again?

@FranzBusch
Copy link
Member

We have to wait for a new compiler/Xcode release that includes this fix and then we can ship it again. We don't want to add the APIs only for Linux right now but also for Darwin. Once the releases have shipped we will add them back with the appropriate compiler guards around them.

For the time being you can probably just copy what we have backed out and it will work as long as you don't deploy to older iOS/macOS/etc. versions.

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

No branches or pull requests

9 participants