-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Description
Hey there, thanks for sharing talc! I'm looking at potentially using it for mnemos, which currently uses linked-list-allocator.
I wanted to see how it fared in miri, and first ran into the problem that the benchmarks use an x86_64 asm call, which didn't build on my aarch64 mac:
error[E0433]: failed to resolve: could not find `x86_64` in `arch`
--> examples/simple_chunk_allocator_bench.rs:90:45
|
90 | let mut now_fn = || unsafe { std::arch::x86_64::__rdtscp(std::ptr::addr_of_mut!(x)) };
| ^^^^^^ could not find `x86_64` in `arch`
I removed that file, and ran cargo +nightly miri test, and hit some errors pretty quickly:
Running unittests src/lib.rs (target/miri/aarch64-apple-darwin/debug/deps/talc-3f2d44bc7b7dff89)
running 3 tests
test llist::tests::dostuff ... warning: integer-to-pointer cast
--> src/llist.rs:38:30
|
38 | debug_assert!(node > 0x1000 as _);
| ^^^^^^^^^^^ integer-to-pointer cast
|
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
= help: which means that Miri might miss pointer bugs in this program.
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
= note: BACKTRACE:
= note: inside `llist::LlistNode::insert` at src/llist.rs:38:30: 38:41
note: inside `llist::tests::dostuff`
--> src/llist.rs:135:13
|
135 | LlistNode::insert(&mut y, LlistNode::next_ptr(&mut x), None);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> src/llist.rs:129:18
|
128 | #[test]
| ------- in this procedural macro expansion
129 | fn dostuff() {
| ^
= note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: integer-to-pointer cast
--> src/llist.rs:39:38
|
39 | debug_assert!(next_of_prev > 0x1000 as _);
| ^^^^^^^^^^^ integer-to-pointer cast
|
= note: inside `llist::LlistNode::insert` at src/llist.rs:39:38: 39:49
note: inside `llist::tests::dostuff`
--> src/llist.rs:135:13
|
135 | LlistNode::insert(&mut y, LlistNode::next_ptr(&mut x), None);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> src/llist.rs:129:18
|
128 | #[test]
| ------- in this procedural macro expansion
129 | fn dostuff() {
| ^
= note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: integer-to-pointer cast
--> src/llist.rs:57:30
|
57 | debug_assert!(node > 0x1000 as _);
| ^^^^^^^^^^^ integer-to-pointer cast
|
= note: inside `llist::LlistNode::remove` at src/llist.rs:57:30: 57:41
note: inside `llist::tests::dostuff`
--> src/llist.rs:148:13
|
148 | LlistNode::remove(&mut z);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> src/llist.rs:129:18
|
128 | #[test]
| ------- in this procedural macro expansion
129 | fn dostuff() {
| ^
= note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: integer-to-pointer cast
--> src/llist.rs:60:38
|
60 | debug_assert!(next_of_prev > 0x1000 as _);
| ^^^^^^^^^^^ integer-to-pointer cast
|
= note: inside `llist::LlistNode::remove` at src/llist.rs:60:38: 60:49
note: inside `llist::tests::dostuff`
--> src/llist.rs:148:13
|
148 | LlistNode::remove(&mut z);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> src/llist.rs:129:18
|
128 | #[test]
| ------- in this procedural macro expansion
129 | fn dostuff() {
| ^
= note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
error: Undefined Behavior: attempting a write access using <95150> at alloc30170[0x0], but that tag does not exist in the borrow stack for this location
--> src/llist.rs:61:9
|
61 | *next_of_prev = next;
| ^^^^^^^^^^^^^^^^^^^^
| |
| attempting a write access using <95150> at alloc30170[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of an access at alloc30170[0x0..0x8]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <95150> was created by a SharedReadWrite retag at offsets [0x0..0x10]
--> src/llist.rs:136:59
|
136 | LlistNode::insert(&mut z, LlistNode::next_ptr(&mut x), Some(NonNull::from(&mut y)));
| ^^^^^^
help: <95150> was later invalidated at offsets [0x0..0x10] by a Unique retag
--> src/llist.rs:138:67
|
138 | let mut iter = LlistNode::iter_mut(Some(NonNull::from(&mut x)));
| ^^^^^^
= note: BACKTRACE (of the first span):
= note: inside `llist::LlistNode::remove` at src/llist.rs:61:9: 61:29
note: inside `llist::tests::dostuff`
--> src/llist.rs:148:13
|
148 | LlistNode::remove(&mut z);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> src/llist.rs:129:18
|
128 | #[test]
| ------- in this procedural macro expansion
129 | fn dostuff() {
| ^
= note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
I'll take a look at this later this weekend, I also helped linked-list-allocator to build cleanly with miri tests (issue: rust-osdev/linked-list-allocator#61, pr: rust-osdev/linked-list-allocator#62) and would be interested in helping if you're open to it!
Metadata
Metadata
Assignees
Labels
No labels