Skip to content
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

linkme crate not supported by Miri #4171

Open
nazar-pc opened this issue Feb 2, 2025 · 6 comments
Open

linkme crate not supported by Miri #4171

nazar-pc opened this issue Feb 2, 2025 · 6 comments
Labels
A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@nazar-pc
Copy link

nazar-pc commented Feb 2, 2025

This is probably related to #2757, but I'm less interested in suppressing it and more in being able to use it.

Specifically, I'm using linkme crate and would like to be able to run tests under Miri. Right now I'm getting this instead:

test basic ... error: unsupported operation: extern static `__start_linkme_CONTRACTS_METHODS_FN_POINTERS` is not supported by Miri
   --> /web/github/abundance/crates/contracts/ab-contracts-executor/src/lib.rs:803:13
    |
803 |             CONTRACTS_METHODS_FN_POINTERS
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extern static `__start_linkme_CONTRACTS_METHODS_FN_POINTERS` is not supported by Miri
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
    = note: BACKTRACE on thread `basic`:
    = note: inside `ab_contracts_executor::NativeExecutor::in_memory` at /web/github/abundance/crates/contracts/ab-contracts-executor/src/lib.rs:803:13: 803:42
note: inside `basic`
   --> crates/contracts/ab-contract-example/tests/basic.rs:13:24
    |
13  |     let mut executor = NativeExecutor::in_memory(shard_index).unwrap();
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
   --> crates/contracts/ab-contract-example/tests/basic.rs:9:11
    |
8   | #[test]
    | ------- in this procedural macro expansion
9   | fn basic() {
    |           ^
    = note: inside `<{closure@crates/contracts/ab-contract-example/tests/basic.rs:9:1: 27:2} as std::ops::FnOnce<()>>::call_once - shim` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
    = note: inside `<fn() -> std::result::Result<(), std::string::String> as std::ops::FnOnce<()>>::call_once - shim(fn() -> std::result::Result<(), std::string::String>)` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
    = note: inside `test::__rust_begin_short_backtrace::<std::result::Result<(), std::string::String>, fn() -> std::result::Result<(), std::string::String>>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:632:18: 632:21
    = note: inside `test::types::RunnableTest::run` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/types.rs:145:40: 145:71
    = note: inside closure at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:655:60: 655:79
    = note: inside `<std::panic::AssertUnwindSafe<{closure@test::run_test_in_process::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9: 272:19
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<{closure@test::run_test_in_process::{closure#0}}>, std::result::Result<(), std::string::String>>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:568:40: 568:43
    = note: inside `std::panicking::r#try::<std::result::Result<(), std::string::String>, std::panic::AssertUnwindSafe<{closure@test::run_test_in_process::{closure#0}}>>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:531:19: 531:88
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@test::run_test_in_process::{closure#0}}>, std::result::Result<(), std::string::String>>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14: 358:33
    = note: inside `test::run_test_in_process` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:655:27: 655:81
    = note: inside closure at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:576:43: 584:18
    = note: inside closure at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:606:41: 606:83
    = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@test::run_test::{closure#1}}, ()>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:152:18: 152:21
    = note: inside closure at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:564:17: 564:71
    = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9: 272:19
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}::{closure#0}}>, ()>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:568:40: 568:43
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}::{closure#0}}>>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:531:19: 531:88
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}::{closure#0}}>, ()>` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14: 358:33
    = note: inside closure at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:562:30: 565:16
    = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce()> as std::ops::FnOnce<()>>::call_once` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1970:9: 1970:52
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1970:9: 1970:52
    = note: inside `std::sys::pal::unix::thread::Thread::new::thread_start` at /home/nazar-pc/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/thread.rs:106:17: 106:64
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
$ cargo miri --version
miri 0.1.0 (bdc6b3de48 2024-12-23)
@oli-obk
Copy link
Contributor

oli-obk commented Feb 2, 2025

Miri doesn't support the linker hacks that linkme is using. Few platforms do. We'd either have to have some sort of impl for all the platforms linkme supports or we'd add one impl and linkme would need to cfg(miri) that one on all platforms

@nazar-pc
Copy link
Author

nazar-pc commented Feb 2, 2025

One impl and custom support in linkme makes much more sense to me than supporting linker hacks in Miri

@RalfJung
Copy link
Member

RalfJung commented Feb 2, 2025 via email

@nazar-pc
Copy link
Author

nazar-pc commented Feb 2, 2025

Switched to inventory that works even better for my needs, which works under Miri

@RalfJung
Copy link
Member

RalfJung commented Feb 2, 2025 via email

@nazar-pc
Copy link
Author

nazar-pc commented Feb 2, 2025

Indeed, spoke too soon 😅
But there is already #450 for that.

@RalfJung RalfJung changed the title unsupported operation: extern static linkme crate not supported by Miri Feb 2, 2025
@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-shims Area: This affects the external function shims labels Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

3 participants