forked from rust-lang/miri
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
234 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/fail-dep/concurrency/libc_pthread_mutex_move.init.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: Undefined Behavior: pthread_mutex_t can't be moved after first use | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | libc::pthread_mutex_lock(&mut m2 as *mut _); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved after first use | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `check` at $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
note: inside `main` | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | check(); | ||
| ^^^^^^^ | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
20 changes: 20 additions & 0 deletions
20
tests/fail-dep/concurrency/libc_pthread_mutex_move.lock.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: Undefined Behavior: pthread_mutex_t can't be moved after first use | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | libc::pthread_mutex_lock(&mut m2 as *mut _); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved after first use | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `check` at $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
note: inside `main` | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | check(); | ||
| ^^^^^^^ | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//@ignore-target-windows: No pthreads on Windows | ||
//@revisions: lock trylock unlock init | ||
|
||
fn main() { | ||
check(); | ||
} | ||
|
||
#[cfg(init)] | ||
fn check() { | ||
unsafe { | ||
let mut m: libc::pthread_mutex_t = std::mem::zeroed(); | ||
assert_eq!(libc::pthread_mutex_init(&mut m as *mut _, std::ptr::null()), 0); | ||
|
||
let mut m2 = m; | ||
libc::pthread_mutex_lock(&mut m2 as *mut _); //~[init] ERROR: pthread_mutex_t can't be moved after first use | ||
} | ||
} | ||
|
||
#[cfg(lock)] | ||
fn check() { | ||
unsafe { | ||
let mut m: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; | ||
libc::pthread_mutex_lock(&mut m as *mut _); | ||
// libc::pthread_mutex_unlock(&mut m as *mut _); | ||
|
||
let mut m2 = m; | ||
libc::pthread_mutex_lock(&mut m2 as *mut _); //~[lock] ERROR: pthread_mutex_t can't be moved after first use | ||
} | ||
} | ||
|
||
#[cfg(trylock)] | ||
fn check() { | ||
unsafe { | ||
let mut m: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; | ||
libc::pthread_mutex_trylock(&mut m as *mut _); | ||
// libc::pthread_mutex_unlock(&mut m as *mut _); | ||
|
||
let mut m2 = m; | ||
libc::pthread_mutex_trylock(&mut m2 as *mut _); //~[trylock] ERROR: pthread_mutex_t can't be moved after first use | ||
} | ||
} | ||
|
||
#[cfg(unlock)] | ||
fn check() { | ||
unsafe { | ||
let mut m: libc::pthread_mutex_t = libc::PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; | ||
libc::pthread_mutex_unlock(&mut m as *mut _); | ||
|
||
let mut m2 = m; | ||
libc::pthread_mutex_unlock(&mut m2 as *mut _); //~[unlock] ERROR: pthread_mutex_t can't be moved after first use | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: Undefined Behavior: pthread_mutex_t can't be moved | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | libc::pthread_mutex_lock(&mut mutex2 as *mut _); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `main` at $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
20 changes: 20 additions & 0 deletions
20
tests/fail-dep/concurrency/libc_pthread_mutex_move.trylock.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: Undefined Behavior: pthread_mutex_t can't be moved after first use | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | libc::pthread_mutex_trylock(&mut m2 as *mut _); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved after first use | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `check` at $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
note: inside `main` | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | check(); | ||
| ^^^^^^^ | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
20 changes: 20 additions & 0 deletions
20
tests/fail-dep/concurrency/libc_pthread_mutex_move.unlock.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: Undefined Behavior: pthread_mutex_t can't be moved after first use | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | libc::pthread_mutex_unlock(&mut m2 as *mut _); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved after first use | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= note: BACKTRACE: | ||
= note: inside `check` at $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
note: inside `main` | ||
--> $DIR/libc_pthread_mutex_move.rs:LL:CC | ||
| | ||
LL | check(); | ||
| ^^^^^^^ | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|