Skip to content

test unwinding past topmost frame of a stack #1494

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

Merged
merged 2 commits into from
Aug 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21867225a74d3b07c2b65e32c67f45197db36896
dfe1e3b641abbede6230e3931d14f0d43e5b8e54
24 changes: 24 additions & 0 deletions tests/compile-fail/concurrency/unwind_top_of_stack.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ignore-windows: Concurrency on Windows is not supported yet.
// error-pattern: unwinding past the topmost frame of the stack

//! Unwinding past the top frame of a stack is Undefined Behavior.
#![feature(rustc_private)]

extern crate libc;

use std::{mem, ptr};

extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
panic!()
}

fn main() {
unsafe {
let mut native: libc::pthread_t = mem::zeroed();
let attr: libc::pthread_attr_t = mem::zeroed();
// assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
}
}
22 changes: 12 additions & 10 deletions tests/run-pass/linked-list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(linked_list_extras)]
#![feature(linked_list_cursors)]
use std::collections::LinkedList;

fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
@@ -9,25 +9,27 @@ fn main() {
let mut m = list_from(&[0, 2, 4, 6, 8]);
let len = m.len();
{
let mut it = m.iter_mut();
it.insert_next(-2);
let mut it = m.cursor_front_mut();
it.insert_before(-2);
loop {
match it.next() {
match it.current().copied() {
None => break,
Some(elt) => {
it.insert_next(*elt + 1);
match it.peek_next() {
Some(x) => assert_eq!(*x, *elt + 2),
None => assert_eq!(8, *elt),
Some(x) => assert_eq!(*x, elt + 2),
None => assert_eq!(8, elt),
}
it.insert_after(elt + 1);
it.move_next(); // Move by 2 to skip the one we inserted.
it.move_next();
}
}
}
it.insert_next(0);
it.insert_next(1);
it.insert_before(99);
it.insert_after(-10);
}

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