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-15035] Encoding data with String.fastestEncoding seems to result in invalid JSON #3363

Open
franklinsch opened this issue Aug 6, 2021 · 0 comments

Comments

@franklinsch
Copy link
Member

Previous ID SR-15035
Radar rdar://81608644
Original Reporter @franklinsch
Type Bug

Attachment: Download

Environment

Ubuntu 18.04 using the toolchain swift-5.5-DEVELOPMENT-SNAPSHOT-2021-08-04-a-ubuntu18.04, which has:

Swift version 5.5-dev (LLVM 4afce2110750060, Swift 4ae44a5e0eac8a0)
Target: x86_64-unknown-linux-gnu

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

md5: 413f2dd3d043273f63044f446290e2a6

Issue Description:

On Ubuntu 18.04 using the toolchain swift-5.5-DEVELOPMENT-SNAPSHOT-2021-08-04-a-ubuntu18.04, which has:
Swift version 5.5-dev (LLVM 4afce2110750060, Swift 4ae44a5e0eac8a0)
Target: x86_64-unknown-linux-gnu

I’m seeing this error when decoding a JSON string that’s been encoded with `fastestEncoding`:

Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Foundation.JSONError.unexpectedCharacter(ascii: 255, characterIndex: 0))))

See the attached program, which crashed on Ubuntu 18.04 but not macOS. The program doesn’t crash on Ubuntu when hardcoding `.utf8` instead of `string.fastestEncoding`.

@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
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

1 participant