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-13563] Data.advanced(by:) crashes when result Data would be empty #3970

Open
swift-ci opened this issue Sep 18, 2020 · 2 comments
Open

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13563
Radar rdar://problem/69169354
Original Reporter benjohn (JIRA User)
Type Bug

Attachment: Download

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

md5: 44b2af155ee2643aca628d439789b4cb

Issue Description:

A `Data` can be constructed empty: The expression `let data = Data()` is valid and does not crash.

Supporting an empty `Data` is useful. It allows for consistent and generic code that doesn't need to consider additional details when a source of data has become exhausted, or when there is no data to work with.

It seems reasonable to expect that the method `advanced(by🙂` on `Data` should be able to handle a case where the resulting `Data` will be empty.

However, these examples crash:

```

let data1 = Data().advanced(by:0)

let data2 = Data([UInt8()]).advanced(by:1)

```

The error is:

"error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation."

I've attached a playground screen shot that shows more detail about the crash being in `Foundation.Data.advanced(by🙂`.

This happens in Playgrounds and Xcode unit tests. I've not tested other platforms.

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Contributor Author

Comment by Udit Ajmera (JIRA)

theindigamer (JIRA User) please provide more info to work on the bug

@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

2 participants