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.
Auto merge of rust-lang#3585 - devnexen:aligned_alloc, r=RalfJung
support aligned_alloc for unixes. Fixes rust-lang#3577
- Loading branch information
Showing
6 changed files
with
171 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ignore-target-windows: Windows does not support the standard C11 aligned_alloc. | ||
|
||
fn main() { | ||
// libc doesn't have this function (https://github.com/rust-lang/libc/issues/3689), | ||
// so we declare it ourselves. | ||
extern "C" { | ||
fn aligned_alloc(alignment: libc::size_t, size: libc::size_t) -> *mut libc::c_void; | ||
} | ||
|
||
// Make sure even zero-sized allocations need to be freed. | ||
|
||
unsafe { | ||
aligned_alloc(2, 0); //~ERROR: memory leaked | ||
} | ||
} |
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: memory leaked: ALLOC (C heap, size: 0, align: 2), allocated here: | ||
--> $DIR/aligned_alloc_size_zero_leak.rs:LL:CC | ||
| | ||
LL | aligned_alloc(2, 0); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `main` at $DIR/aligned_alloc_size_zero_leak.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
note: the evaluated program leaked memory, pass `-Zmiri-ignore-leaks` to disable this check | ||
|
||
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