Skip to content

Commit 8a28eaa

Browse files
committed
Auto merge of #1494 - RalfJung:stack-unwind-top, r=RalfJung
test unwinding past topmost frame of a stack This tests rust-lang/rust#74984
2 parents 7b970ef + 5d22145 commit 8a28eaa

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
21867225a74d3b07c2b65e32c67f45197db36896
1+
dfe1e3b641abbede6230e3931d14f0d43e5b8e54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ignore-windows: Concurrency on Windows is not supported yet.
2+
// error-pattern: unwinding past the topmost frame of the stack
3+
4+
//! Unwinding past the top frame of a stack is Undefined Behavior.
5+
6+
#![feature(rustc_private)]
7+
8+
extern crate libc;
9+
10+
use std::{mem, ptr};
11+
12+
extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
13+
panic!()
14+
}
15+
16+
fn main() {
17+
unsafe {
18+
let mut native: libc::pthread_t = mem::zeroed();
19+
let attr: libc::pthread_attr_t = mem::zeroed();
20+
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
21+
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
22+
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
23+
}
24+
}

tests/run-pass/linked-list.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(linked_list_extras)]
1+
#![feature(linked_list_cursors)]
22
use std::collections::LinkedList;
33

44
fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
@@ -9,25 +9,27 @@ fn main() {
99
let mut m = list_from(&[0, 2, 4, 6, 8]);
1010
let len = m.len();
1111
{
12-
let mut it = m.iter_mut();
13-
it.insert_next(-2);
12+
let mut it = m.cursor_front_mut();
13+
it.insert_before(-2);
1414
loop {
15-
match it.next() {
15+
match it.current().copied() {
1616
None => break,
1717
Some(elt) => {
18-
it.insert_next(*elt + 1);
1918
match it.peek_next() {
20-
Some(x) => assert_eq!(*x, *elt + 2),
21-
None => assert_eq!(8, *elt),
19+
Some(x) => assert_eq!(*x, elt + 2),
20+
None => assert_eq!(8, elt),
2221
}
22+
it.insert_after(elt + 1);
23+
it.move_next(); // Move by 2 to skip the one we inserted.
24+
it.move_next();
2325
}
2426
}
2527
}
26-
it.insert_next(0);
27-
it.insert_next(1);
28+
it.insert_before(99);
29+
it.insert_after(-10);
2830
}
2931

3032
assert_eq!(m.len(), 3 + len * 2);
3133
assert_eq!(m.into_iter().collect::<Vec<_>>(),
32-
[-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]);
34+
[-10, -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 99]);
3335
}

0 commit comments

Comments
 (0)