-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Unable To Append Two Emoji Strings On macOS Ventura's Swift #63664
Comments
I'm not able to reproduce the error. Could there be some bugs in your |
appending is in the StringProtocol. https://developer.apple.com/documentation/swift/stringprotocol/appending(_:) |
FWIW I also am not able to reproduce the crash on Xcode Version 14.2 (14C18). Ventura 13.2.1 (22D68). (swiftlang-5.7.2.135.5 clang-1400.0.29.51) |
I'm going to close this for now since it feels like we're missing a step somewhere in the repro (or some specific machine configuration). |
Yes, but regrettably the documentation does not mention that the function is declared in Foundation, not the Standard Library. @brianmichel Does |
@AnthonyLatsis Foundation needs to be imported first. This is what I see (note use of
Note that adding an explicit
(this is on Ventura 13.2.1 (22D68) on a 2021 M1 Pro) |
When I follow precisely the same steps as @fischman-bcny, on the same OS, also with an M1 (Max) MacBook Pro, I don't see the same crash. Could we be getting different Foundations?
|
Thanks for clarifying. One more thing: Does it crash if you interpret it with // file.swift
import Foundation
let _ = "\u{26D3}".appending("\u{1F991}") |
Not if you both have a single Xcode installed and their versions match, but you can check for certain with |
@AnthonyLatsis this is what I see:
|
cc @parkera |
Ping :) |
CC: @lorentey - in case something about the bridging stands out to him |
The crash may be due to a bug in one of these related String changes: I'll take a closer look. |
One very reliable workaround is to avoid calling |
This is reliably reproducible by overriding Core Foundation's default text encoding from Mac OS Roman to UTF-8:
This switches concatenation to a different algorithm, which exhibits the issue. I'm continuing to investigate. (UTF-8 is likely to be the default text encoding at least in some regions, but evidently not all.) |
@lorentey the tip to use Re: encoding/locale: note that up-thread there are |
@fischman-bcny If the environment variable isn't set, Core Foundation has a legacy fallback to get its default encoding from the file (Defaulting to anything other than UTF-8 doesn't make much sense to me these days, but fwiw it appears my Mac (in the US region) is still configured to prefer Mac Roman in this context. π€·πΌββοΈ) |
@lorentey nice! Indeed, I have a |
It turns out that the fault lies is outside of the Swift stdlib in this case, although it got triggered by Swift 5.7 in Ventura starting to trap on more out-of-bounds string accesses. We're tracking this issue separately (rdar://108765311); the fix will ship in a future OS release. @fischman-bcny Do you happen to remember if you manually edited that file to set those contents, or if something configured it automatically? |
@lorentey not sure, sorry. |
@lorentey Is the issue with Foundation after all? If so, perhaps we should transfer the issue to the newly published Foundation repository? |
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. |
Description
Appending two emoji strings together crashes on macOS Ventura
Steps to reproduce
"β".appending("π¦")
in the Swift replExpected 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-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 14.2
-- Build version 14C18
Sample Project
FuzzyMatchingPackage.zip
The text was updated successfully, but these errors were encountered: