-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Yet another bug with slice_patterns #26619
Comments
You mean filter_map? Using ref on the closure's argument is suspect, maybe we can reproduce using that. |
Oh no, it's probably make_entry that's entirely broken. Slice patterns are busted and you basically can't use them right now if you want safe rust. It's an unstable feature, fortunately. |
@bluss Yes, you are right - I'm not sure that is the case. I tried with different things and could not reproduce it. I suspect the fact that compiler didn't error on returning I'm complete newbie in Rust, so I fail to easily come up with bug-reproducing snippet. You might need to provide me some guidance here ;( |
@bluss So, you are saying it's more likely to be because of slice patterns being used and I should expect this kind of errors when using unstable features in nightly channel. Makes sense. Should I close this issue than? Or should it stay open as a reminder / something that will needs to be re-checked in next beta/stable? |
Let it stay open unless it's already been reported. Your bug looks a bit different than the other soundness issues reported for slice patterns. My recommendation: don't enable the feature flag slice_patterns. It is a serious memory safety issue. Being restricted to an unstable feature gate is better, but we still want rust to be safe even there. |
|
Triage: this branch no longer builds:
Following that issue, if we patch it: - if let [commit, name, time, comment] = &parts[..] {
+ if let &[commit, name, time, comment] = &parts[..] { then we get a different error: error: borrowed value does not live long enough
--> src/history.rs:65:36
|
65 | .filter_map(|ref line| self.make_entry(line))
| ^^^^^^^^ - temporary value only lives until here
| |
| does not live long enough
|
= note: borrowed value must be valid for the anonymous lifetime #1 defined on unknown free region bounded by scope CodeExtent(1511/CallSiteScope { fn_id: NodeId(566), body_id: NodeId(2401) })... that error is, uh, not great. But I think that means the soundness issue is fixed? |
Sure enough. I basically fixed all of the crazy slice_patterns bugs. |
Reopening as E-needstest. |
I simplified the example to the next
And it was not a bug in slice patterns, valgrind still detects error if uncomment (3) and comment (2). And invalid output is generated if comment (1) but valgrind doesn't detect anything. I it tested on nightly-2015-06-25, for current version need to add |
This of course still gives the expected lifetime error as in #26619 (comment) - and is not a bug in slice patterns. Do you think it is worth bisecting or adding a test? |
…hton Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes rust-lang#10876. Closes rust-lang#22892. Closes rust-lang#26448. Closes rust-lang#26577. Closes rust-lang#26619. Closes rust-lang#27054. Closes rust-lang#28587. Closes rust-lang#44127. Closes rust-lang#44255. Closes rust-lang#55731. Closes rust-lang#57781.
…hton Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes rust-lang#10876. Closes rust-lang#22892. Closes rust-lang#26448. Closes rust-lang#26577. Closes rust-lang#26619. Closes rust-lang#27054. Closes rust-lang#28587. Closes rust-lang#44127. Closes rust-lang#44255. Closes rust-lang#55731. Closes rust-lang#57781.
…hton Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes rust-lang#10876. Closes rust-lang#22892. Closes rust-lang#26448. Closes rust-lang#26577. Closes rust-lang#26619. Closes rust-lang#27054. Closes rust-lang#28587. Closes rust-lang#44127. Closes rust-lang#44255. Closes rust-lang#55731. Closes rust-lang#57781.
…hton Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes rust-lang#10876. Closes rust-lang#22892. Closes rust-lang#26448. Closes rust-lang#26577. Closes rust-lang#26619. Closes rust-lang#27054. Closes rust-lang#28587. Closes rust-lang#44127. Closes rust-lang#44255. Closes rust-lang#55731. Closes rust-lang#57781.
Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes #10876. Closes #26448. Closes #26577. Closes #26619. Closes #27054. Closes #44127. Closes #44255. Closes #55731. Closes #57781.
…hton Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes rust-lang#10876. Closes rust-lang#26448. Closes rust-lang#26577. Closes rust-lang#26619. Closes rust-lang#27054. Closes rust-lang#44127. Closes rust-lang#44255. Closes rust-lang#55731. Closes rust-lang#57781.
Add tests for several E-needstest issues This PR adds a number of tests for various `E-needstest` errors. These tend to have been left open for a long time and seem unlikely to be closed otherwise. Closes #10876. Closes #26448. Closes #26577. Closes #26619. Closes #27054. Closes #44127. Closes #44255. Closes #55731. Closes #57781.
I'm not particularly sure. It's either the bug with compiler failing to enforce lifetime rule or data corruption in Iterator
flat_map
filter_map
(Updated).I tried code found at https://github.com/leonardinius/git-wayback-machine.rs/tree/rust-bug:
Unfortunately I fail to reproduce the bug in different conditions and fail to create standalone code snippet to reproduce the bug.
How to repeat:
I expected to see this happen:
Since they iterate the same vector data before and after
flat_map
(See history.rs#L62-L71) I expect the following lines to be as follows.Instead, this happened: See lines below. Line
3 Page - Inspect 1-2: Entry:
and3 Page - Inspect 2-2: Entry:
entries should read the same.My assumptions / what went wrong:
flat_map
Option<Entry>
without reference classifierMeta
rustc --version --verbose
:Backtrace:
No backtrace
Please do not hesitate to ask me for more information and standalone code snippets, however you might need to help me to create those ;)
The text was updated successfully, but these errors were encountered: