swift: Unable To Append Two Emoji Strings On macOS Ventura's Swift
Description Appending two emoji strings together crashes on macOS Ventura
Steps to reproduce
- Use macOS Ventura
- Run the sample package’s tests or
- try to execute the code
"⛓".appending("🦑")
in the Swift repl
Expected behavior This code should run and execute fine producing a string that is equal to “⛓🦑”
Actual behavior
This works correctly on macOS Monterey, but crashes on macOS Ventura with the message Swift/StringUTF16View.swift:144: Fatal error: String index is out of bounds
Environment
- Swift compiler version info – swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51) – Target: arm64-apple-macosx13.0
- Xcode version info – Xcode 14.2 – Build version 14C18
- Deployment target: macOS 11
Sample Project FuzzyMatchingPackage.zip
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 23 (14 by maintainers)
It is a Foundation issue, but it does not involve the code in swift-foundation. I think it’s okay to keep the issue here for now.
@lorentey the tip to use
+
worked a treat for the reliable crash in our app; thanks!Re: encoding/locale: note that up-thread there are
env -i
-based repro recipes that should have isolated the results from the contents of my environment, yet others fail to reproduce the crash. Curious if you know of other places besides the environment where encoding/locale/etc info might be sneaking into the mix (that might differ in your/my systems from those of others’ who have failed to repro the crash).One very reliable workaround is to avoid calling
StringProtocol.appending
, preferring to use the Swift native+
operator instead. (There are no drawbacks to doing that. Besides investigating the potential stdlib issue, I’ll also try to change the implementation ofappending
to do the same. However, that change will not apply retroactively, even if it ends up shipping.+
does the right thing on all platforms.)@AnthonyLatsis this is what I see: