-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
When trying to write a data structure that wraps a Vec
and is a Placer
, I got a segfault when trying to use the result of place_back()
as a Place
.
I tried this code:
#![feature(collection_placement)]
#![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
use std::ops::Placer;
use std::vec::PlaceBack;
fn main() {
let mut stack = Stack::new();
&mut stack <- 1;
println!("Doesn't get here!");
}
pub struct Stack(Vec<u32>);
impl Stack {
pub fn new() -> Self {
Stack(Vec::new())
}
}
impl<'a> Placer<u32> for &'a mut Stack {
type Place = PlaceBack<'a, u32>;
fn make_place(self) -> Self::Place {
self.0.place_back() //.make_place()
}
}
I expected to see this happen: Prints "Doesn't get here!", and exits with code 0.
Instead, this happened: Prints "Segmentation fault", and exits with code 139.
The error is fixed by uncommenting .make_place()
.
Meta
rustc --version --verbose
:
rustc 1.22.0-nightly (fd4bef5 2017-09-15)
binary: rustc
commit-hash: fd4bef5
commit-date: 2017-09-15
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0
Backtrace:
N/A?
scottmcm
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.