-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Segmentation Fault while iterating over a vector of "~[~T as Trait]" #5666
Comments
I've been fiddling around with this example some more, here's what I've dug up. If I instead store the vector as Printing Printing the length on a vector Attempting to access an out of bounds index still panics as expected; so I believe the segmentation fault is a combination of using the iterator and the storage of |
Reproduced with 64963d6. Nominating for milestone 5, production-ready |
Cannot reproduce with: struct Dog {
name : ~str
}
trait Barks {
fn bark(&self) -> ~str;
}
impl Barks for Dog {
fn bark(&self) -> ~str {
return fmt!("woof! (I'm %s)", self.name);
}
}
fn main() {
let snoopy = ~Dog{name: ~"snoopy"};
let bubbles = ~Dog{name: ~"bubbles"};
let barker = [snoopy as ~Barks, bubbles as ~Barks];
for barker.iter().advance |pup| {
println(fmt!("%s", pup.bark()));
}
} Probably fixed by @luqmana's |
(Removing nomination) |
Rollup of 3 pull requests Successful merges: - rust-lang#5637 (new lint: vec_resize_to_zero) - rust-lang#5656 (len_zero: skip ranges if feature `range_is_empty` is not enabled) - rust-lang#5663 (add testcase that no longer ICEs) Failed merges: r? @ghost changelog: rollup
Tested in rust 0.6 on Arch (Linux - 3.8.4, x86_64)
Modified testcase exhibits similar behavior on Mac OS X 10.7
I can call
#bark()
on any index of the vector and it does not seg-fault.When using the
#each()
iterator however, only the first element is printed, the next access results in a segmentation fault.I've been able to reproduce this on two separate systems, one running rust 0.6 (6dd20c8) on a fairly vanilla Linux kernel, the other running (release-0.5) on Mac OS X.
I've written a small test-case that exhibits this behavior on my systems.
Note
Please let me know if I can gather any additional information that might aid in resolving this issue.
The text was updated successfully, but these errors were encountered: