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

[SR-3509] Foundation CharacterSet Crash #4306

Closed
swift-ci opened this issue Dec 30, 2016 · 2 comments
Closed

[SR-3509] Foundation CharacterSet Crash #4306

swift-ci opened this issue Dec 30, 2016 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-3509
Radar None
Original Reporter bnut (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

xcodebuild -version Xcode 8.2 Build version 8C38

swift --version Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: b6a77aabb80a8d86278845247ab9a265

Issue Description:

The following code causes a crash in foundation at runtime:

var set = CharacterSet()
set.insert("\u{D7FF}") // no crash
set.insert("\u{D7FF}") // no crash
set.insert(charactersIn: "\u{D7FE}"..."\u{D7FF}") // crashes

According to the UnicodeScalar.init(_:UInt32) source, 0xD7FF is a valid character:

    //     * As a result of this definition, the set of Unicode scalar values
    //     consists of the ranges 0 to D7FF and E000 to 10FFFF, inclusive.

https://github.com/apple/swift/blob/2fe4254cb712fa101a220f95b6ade8f99f43dc74/stdlib/public/core/UnicodeScalar.swift#L97

I suspect there is an edge case where 0xD7FF is accidentally excluded.

@Dante-Broggi
Copy link

Interestingly, in the Xcode 9.4.1 toolchain on a Mac, the behavior is reversed:

var set = CharacterSet()
set.insert(charactersIn: "\u{D7FE}"..."\u{D7FF}") // no crash
set.insert("\u{D7FF}") // crashes

@spevans
Copy link
Collaborator

spevans commented Feb 9, 2020

This now works without crashing, tested on swift 5.1 (Xcode 11.3.1) and swift-5.1.3 on Ubuntu18

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants