[SR-11749] Crash only on iOS when setting subscript for non-final class in other SwiftPM module #54156
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
generics
Feature: generic declarations and types
run-time crash
Bug → crash: Swift code crashed during execution
Attachment: Download
Environment
❯ xcodebuild -version
Xcode 11.2
Build version 11B52
❯ swift --version
Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)
Target: x86_64-apple-darwin19.0.0
Issue occurs on iOS 13.2 simulators and devices. Issue does not occur on macOS 10.15. Have not tested other situations.
Additional Detail from JIRA
md5: 41c97f70c67c490b9198ff1f08d9c0b4
duplicates:
Issue Description:
I've hit an issue where a custom subscript I defined on a type in one of my Swift packages is causing a crash when running on iOS, but not on macOS (either with Catalyst or not).
I've attached a minimal reproduction package, which only shows the issue when running the tests in Xcode on an iOS simulator or device. In my real use case, this issue reproduces in both test cases and when using the package from an app.
I've reduced it down to a class shaped something like this:
The crash is triggered by creating a new instance and setting the subscript with any key/value.
The following details I've found to be important (removing any of them makes the crash go away):
The class must be generic
The class must have a private variable
The class must be non-final
The class must live in a module of a Swift package (the same use case with a class in an iOS framework linked by an app does not reproduce the issue)
I've seen the crash on a stack frame like this:
#0 0x00000001060a1099 in method descriptor for UserActions.Context.subscript.modify
In the attached test case, it's much weirder, as it's referencing a different type than the one the subscript is being called on:
#0 0x0000000102a3aba8 in direct field offset for NotCrashy.data ()
The text was updated successfully, but these errors were encountered: