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-5987] Data.insert(:at:) fails at runtime on sliced Data #4411
Comments
Comment by Raphael (JIRA) On https://swift.sandbox.bluemix.net/#/repl with Swift Dev. 4.0 (Sep 5, 2017) Platform: Linux (x86_64): Error running code:
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
/swiftfiles/doit.sh: line 51: 52 Illegal instruction timeout ${TIMEOUT} .build/debug/TempCode But no error with <= 3.1 Dev |
Likely fixed already. @phausler? |
yup the `data.removeFirst` is a creation of a slice and the `data.insert` was a mutation so this falls into the mutation of slices changes which as been fixed; please verify with a newer toolchain |
Can you verify with a toolchain that contains apple/swift#12011 |
Comment by Raphael (JIRA) (Honest) Questions:
|
1) Partially I presumed the collection unit tests covered similar cases (at least for mutations of slices). Turns out they did not, and I should have taken the time to write the 240+ unit tests before to validate the work further. 4) I think to catch these types of things earlier it would be really good to have coverage reports |
Comment by Raphael (JIRA) 1) Ugh, 240 tests is a lot of wood. At least now all collections are much more rigorously tested, so that's great![]( Thanks for the quick fix, too) 4) This is probably a path coverage issue, though, isn't it? Each method probably works fine in isolation (code coverage close to 100% easy to achieve?). Are there path coverage tools for Swift? 2+3) Great, thanks! We'll see if we have to ship a workaround copying sliced |
Comment by Raphael (JIRA) Sorry to bring this up here, but I have no idea where to find this information resp. ask for it. What's the timeline for 4.0.1? I'm asking because there are other regressions (we use Security Framework via its low-level methods) we have not yet been able to identify the causes of, even after working this specific issue here. But they are gone with the 9.1 beta, so that's good. Anyway, we're kind of stuck at Swift 3.1 and XCode 8.x until the fixes are released. Which is ... not nice. |
Comment by Raphael (JIRA) Unfortunately, the issue persists under XCode 9.1 (9B55) with Swift version 4.0.2. |
This is now correct behavior: your sample has a slight bug: instead of inserting at 0 you really are supposed to insert at the startIndex because the sliced data from removeFirst changes it from being 0 indexes to being a startIndex of 1 |
Comment by Raphael (JIRA) That is an ... unfortunate design choice. Also unfortunate is that there is no descriptive assertion; Thanks for clarifying. |
Environment
Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: 50a048c9a3914aed17d370f936e0f2ae
Issue Description:
Expected:
data == Data(bytes: [1,128])
Actual:
This seems to be a regression from 3.1 –> 4.0
The text was updated successfully, but these errors were encountered: