purpleprotocol / mimalloc_rust

A Rust wrapper over Microsoft's MiMalloc memory allocator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error Testing Miri

GPeaky opened this issue · comments

I am using some unsafe rust in my crate for improve performance and i am getting an error from mimalloc:

Running unittests src/main.rs (target/miri/x86_64-unknown-linux-gnu/debug/deps/intelli-90c2b30ae[563](https://github.com/GPeaky/intelli/actions/runs/7086055819/job/19283534051#step:5:564)c5cb)
error: unsupported operation: can't call foreign function `mi_malloc_aligned` on OS `linux`
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mimalloc-0.1.39/src/lib.rs:46:9
   |
46 |         mi_malloc_aligned(layout.size(), layout.align()) as *mut u8
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `mi_malloc_aligned` on OS `linux`
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `<mimalloc::MiMalloc as std::alloc::GlobalAlloc>::alloc` at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mimalloc-0.1.39/src/lib.rs:46:9: 46:57
note: inside `_::__rust_alloc`
  --> src/main.rs:12:16
   |
11 | #[global_allocator]
   | ------------------- in this procedural macro expansion
12 | static GLOBAL: MiMalloc = MiMalloc;
   |                ^^^^^^^^
   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error```
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

Pretty sure MIRI can't do FFI easily.

Okay!, just other question is there any possible solution to make miri don't check mimalloc or something?

You probably want to disable mimalloc while running under MIRI.

I think cfg_attr should work. If not, you can just put the global_allocator stuff in a module and feature gate that entire module instead.

Thanks!