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

the test example run crash on Windows #9

Open
lij55 opened this issue Aug 31, 2024 · 6 comments
Open

the test example run crash on Windows #9

lij55 opened this issue Aug 31, 2024 · 6 comments

Comments

@lij55
Copy link

lij55 commented Aug 31, 2024

rust version is nightly-x86_64-pc-windows-msvc unchanged - rustc 1.82.0-nightly

error message is:
error: process didn't exit successfully: target\debug\examples\testk.exe (exit code: 0xc0000374, STATUS_HEAP_CORRUPTION)

debug and release build are the same.

@Jobarion
Copy link

Jobarion commented Oct 9, 2024

I'm facing the same issue, I cannot get the example to run

@seijikun
Copy link
Owner

I don't have Windows, so unfortunately I can't test it myself, but let's try to work something out:

Which of the examples did you try to run exactly? I only see testk.exe and that seems weird to me. I would expect either lloyd, minibatch, or status_events.

To debug this, can you please try running the same example using cargo miri and send me the output? For example, to run the lloyd example, do:

cargo miri run --example lloyd

@Jobarion
Copy link

I had to simplify the example, otherwise cargo miri took forever to run. This is the lloyd example with the following parameters:

    let (sample_cnt, sample_dims, k, max_iter) = (5, 2, 4, 10);
PS C:\Users\<user>\Documents\dev\kmean-rs> cargo miri run --example lloyd
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
     Running `C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo-miri.exe runner target\miri\x86_64-pc-windows-msvc\debug\examples\lloyd.exe`
warning: integer-to-pointer cast
   --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:204:11
    |
204 |         &*(ptr as *const T)
    |           ^^^^^^^^^^^^^^^^^ integer-to-pointer cast
    |
    = help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
    = help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.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 set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
    = help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
    = note: BACKTRACE on thread `unnamed-1`:
    = note: inside `<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::deref::<'_>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:204:11: 204:28
    = note: inside `crossbeam_epoch::atomic::Shared::<'_, crossbeam_epoch::internal::Local>::deref` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1421:9: 1421:22
    = note: inside `crossbeam_epoch::sync::list::List::<crossbeam_epoch::internal::Local>::insert` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\sync\list.rs:176:41: 176:58
    = note: inside `crossbeam_epoch::internal::Local::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:330:13: 330:65
    = note: inside `crossbeam_epoch::collector::Collector::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\collector.rs:45:9: 45:30
    = note: inside `crossbeam_epoch::default::HANDLE::__init` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:34:34: 34:56
    = note: inside `<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init} as std::ops::FnOnce<()>>::call_once - shim(fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init})` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
    = note: inside `std::option::Option::<crossbeam_epoch::collector::LocalHandle>::unwrap_or_else::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:1014:21: 1014:24
    = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::initialize::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:64:17: 64:59
    = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::get_or_init::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:56:40: 56:61
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\mod.rs:93:25: 93:54
    = note: inside `<{closure@crossbeam_epoch::default::HANDLE::{constant#0}::{closure#0}} as std::ops::FnOnce<(std::option::Option<&mut std::option::Option<crossbeam_epoch::collector::LocalHandle>>,)>>::call_once - shim` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
    = note: inside `std::thread::LocalKey::<crossbeam_epoch::collector::LocalHandle>::try_with::<{closure@crossbeam_epoch::default::with_handle<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>::{closure#0}}, bool>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:282:37: 282:55
    = note: inside `crossbeam_epoch::default::with_handle::<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:59:5: 60:28
    = note: inside `crossbeam_epoch::default::is_pinned` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:46:5: 46:45
    = note: inside `crossbeam_deque::deque::Stealer::<rayon_core::job::JobRef>::steal` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-deque-0.8.5\src\deque.rs:641:12: 641:30
    = note: inside `rayon_core::registry::WorkerThread::take_local_job` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:751:19: 751:39
    = note: inside `rayon_core::registry::WorkerThread::wait_until_cold` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:785:32: 785:53
    = note: inside `rayon_core::registry::WorkerThread::wait_until::<rayon_core::latch::OnceLatch>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:769:13: 769:40
    = note: inside `rayon_core::registry::WorkerThread::wait_until_out_of_work` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:818:9: 818:65
    = note: inside `rayon_core::registry::main_loop` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:923:5: 923:43
    = note: inside `rayon_core::registry::ThreadBuilder::run` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:53:18: 53:33
    = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:98:20: 98:32
    = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154:18: 154:21
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:521:17: 521:71
    = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557:40: 557:43
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520:19: 520:88
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358:14: 358:33
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:520:30: 522:16
    = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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 C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `std::sys::pal::windows::thread::Thread::new::thread_start` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\windows\thread.rs:55:22: 55:69

warning: integer-to-pointer cast
    --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1345:9
     |
1345 |         raw as *const _
     |         ^^^^^^^^^^^^^^^ integer-to-pointer cast
     |
     = note: BACKTRACE on thread `unnamed-1`:
     = note: inside `crossbeam_epoch::atomic::Shared::<'_, crossbeam_epoch::internal::Local>::as_raw` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1345:9: 1345:24
     = note: inside `crossbeam_epoch::internal::Local::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:332:24: 332:38
     = note: inside `crossbeam_epoch::collector::Collector::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\collector.rs:45:9: 45:30
     = note: inside `crossbeam_epoch::default::HANDLE::__init` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:34:34: 34:56
     = note: inside `<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init} as std::ops::FnOnce<()>>::call_once - shim(fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init})` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
     = note: inside `std::option::Option::<crossbeam_epoch::collector::LocalHandle>::unwrap_or_else::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:1014:21: 1014:24
     = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::initialize::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:64:17: 64:59
     = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::get_or_init::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:56:40: 56:61
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\mod.rs:93:25: 93:54
     = note: inside `<{closure@crossbeam_epoch::default::HANDLE::{constant#0}::{closure#0}} as std::ops::FnOnce<(std::option::Option<&mut std::option::Option<crossbeam_epoch::collector::LocalHandle>>,)>>::call_once - shim` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
     = note: inside `std::thread::LocalKey::<crossbeam_epoch::collector::LocalHandle>::try_with::<{closure@crossbeam_epoch::default::with_handle<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>::{closure#0}}, bool>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:282:37: 282:55
     = note: inside `crossbeam_epoch::default::with_handle::<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:59:5: 60:28
     = note: inside `crossbeam_epoch::default::is_pinned` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:46:5: 46:45
     = note: inside `crossbeam_deque::deque::Stealer::<rayon_core::job::JobRef>::steal` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-deque-0.8.5\src\deque.rs:641:12: 641:30
     = note: inside `rayon_core::registry::WorkerThread::take_local_job` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:751:19: 751:39
     = note: inside `rayon_core::registry::WorkerThread::wait_until_cold` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:785:32: 785:53
     = note: inside `rayon_core::registry::WorkerThread::wait_until::<rayon_core::latch::OnceLatch>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:769:13: 769:40
     = note: inside `rayon_core::registry::WorkerThread::wait_until_out_of_work` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:818:9: 818:65
     = note: inside `rayon_core::registry::main_loop` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:923:5: 923:43
     = note: inside `rayon_core::registry::ThreadBuilder::run` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:53:18: 53:33
     = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:98:20: 98:32
     = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154:18: 154:21
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:521:17: 521:71
     = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557:40: 557:43
     = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520:19: 520:88
     = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358:14: 358:33
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:520:30: 522:16
     = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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 C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
     = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
     = note: inside `std::sys::pal::windows::thread::Thread::new::thread_start` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\windows\thread.rs:55:22: 55:69

error: Undefined Behavior: trying to retag from <127658> for SharedReadWrite permission at alloc59144[0x8], but that tag does not exist in the borrow stack for this location
   --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:549:9
    |
549 |         &*local_ptr
    |         ^^^^^^^^^^^
    |         |
    |         trying to retag from <127658> for SharedReadWrite permission at alloc59144[0x8], but that tag does not exist in the borrow stack for this location
    |         this error occurs as part of retag at alloc59144[0x0..0x180]
    |
    = 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: <127658> was created by a SharedReadWrite retag at offsets [0x0..0x8]
   --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:548:26
    |
548 |         let local_ptr = (entry as *const Entry).cast::<Self>();
    |                          ^^^^^
    = note: BACKTRACE (of the first span) on thread `unnamed-1`:
    = note: inside `<crossbeam_epoch::internal::Local as crossbeam_epoch::sync::list::IsElement<crossbeam_epoch::internal::Local>>::element_of` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:549:9: 549:20
    = note: inside `<crossbeam_epoch::sync::list::Iter<'_, crossbeam_epoch::internal::Local, crossbeam_epoch::internal::Local> as std::iter::Iterator>::next` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\sync\list.rs:290:37: 290:53
    = note: inside `crossbeam_epoch::internal::Global::try_advance` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:235:22: 235:45
    = note: inside `crossbeam_epoch::internal::Global::collect` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:200:28: 200:51
    = note: inside `crossbeam_epoch::internal::Local::pin` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:435:17: 435:46
    = note: inside `crossbeam_epoch::collector::LocalHandle::pin` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\collector.rs:81:18: 81:37
    = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:40:26: 40:38
    = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:60:23: 60:27
    = note: inside `std::thread::LocalKey::<crossbeam_epoch::collector::LocalHandle>::try_with::<{closure@crossbeam_epoch::default::with_handle<{closure@crossbeam_epoch::default::pin::{closure#0}}, crossbeam_epoch::guard::Guard>::{closure#0}}, crossbeam_epoch::guard::Guard>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:283:12: 283:27
    = note: inside `crossbeam_epoch::default::with_handle::<{closure@crossbeam_epoch::default::pin::{closure#0}}, crossbeam_epoch::guard::Guard>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:59:5: 60:28
    = note: inside `crossbeam_epoch::default::pin` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:40:5: 40:39
    = note: inside `crossbeam_deque::deque::Stealer::<rayon_core::job::JobRef>::steal` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-deque-0.8.5\src\deque.rs:645:22: 645:34
    = note: inside `rayon_core::registry::WorkerThread::take_local_job` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:751:19: 751:39
    = note: inside `rayon_core::registry::WorkerThread::wait_until_cold` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:785:32: 785:53
    = note: inside `rayon_core::registry::WorkerThread::wait_until::<rayon_core::latch::OnceLatch>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:769:13: 769:40
    = note: inside `rayon_core::registry::WorkerThread::wait_until_out_of_work` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:818:9: 818:65
    = note: inside `rayon_core::registry::main_loop` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:923:5: 923:43
    = note: inside `rayon_core::registry::ThreadBuilder::run` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:53:18: 53:33
    = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:98:20: 98:32
    = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154:18: 154:21
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:521:17: 521:71
    = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557:40: 557:43
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520:19: 520:88
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358:14: 358:33
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:520:30: 522:16
    = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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 C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `std::sys::pal::windows::thread::Thread::new::thread_start` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\windows\thread.rs:55:22: 55:69

error: aborting due to 1 previous error; 2 warnings emitted

error: process didn't exit successfully: `C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo-miri.exe runner target\miri\x86_64-pc-windows-msvc\debug\examples\lloyd.exe` (exit code: 1)

@seijikun
Copy link
Owner

Mhm. Weird, I see the same error in Linux. But it reliably doesn't crash.

Just to be sure, can you please also run:

MIRIFLAGS="-Zmiri-disable-stacked-borrows" cargo miri run --example lloyd

@Jobarion
Copy link

Jobarion commented Oct 25, 2024

With set MIRIFLAGS=-Zmiri-disable-stacked-borrows

    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
     Running `C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo-miri.exe runner target\miri\x86_64-pc-windows-msvc\debug\examples\lloyd.exe`
warning: integer-to-pointer cast
   --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:204:11
    |
204 |         &*(ptr as *const T)
    |           ^^^^^^^^^^^^^^^^^ integer-to-pointer cast
    |
    = help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
    = help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.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 set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
    = help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
    = note: BACKTRACE on thread `unnamed-1`:
    = note: inside `<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::deref::<'_>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:204:11: 204:28
    = note: inside `crossbeam_epoch::atomic::Shared::<'_, crossbeam_epoch::internal::Local>::deref` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1421:9: 1421:22
    = note: inside `crossbeam_epoch::sync::list::List::<crossbeam_epoch::internal::Local>::insert` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\sync\list.rs:176:41: 176:58
    = note: inside `crossbeam_epoch::internal::Local::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:330:13: 330:65
    = note: inside `crossbeam_epoch::collector::Collector::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\collector.rs:45:9: 45:30
    = note: inside `crossbeam_epoch::default::HANDLE::__init` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:34:34: 34:56
    = note: inside `<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init} as std::ops::FnOnce<()>>::call_once - shim(fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init})` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
    = note: inside `std::option::Option::<crossbeam_epoch::collector::LocalHandle>::unwrap_or_else::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:1014:21: 1014:24
    = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::initialize::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:64:17: 64:59
    = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::get_or_init::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:56:40: 56:61
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\mod.rs:93:25: 93:54
    = note: inside `<{closure@crossbeam_epoch::default::HANDLE::{constant#0}::{closure#0}} as std::ops::FnOnce<(std::option::Option<&mut std::option::Option<crossbeam_epoch::collector::LocalHandle>>,)>>::call_once - shim` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
    = note: inside `std::thread::LocalKey::<crossbeam_epoch::collector::LocalHandle>::try_with::<{closure@crossbeam_epoch::default::with_handle<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>::{closure#0}}, bool>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:282:37: 282:55
    = note: inside `crossbeam_epoch::default::with_handle::<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:59:5: 60:28
    = note: inside `crossbeam_epoch::default::is_pinned` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:46:5: 46:45
    = note: inside `crossbeam_deque::deque::Stealer::<rayon_core::job::JobRef>::steal` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-deque-0.8.5\src\deque.rs:641:12: 641:30
    = note: inside `rayon_core::registry::WorkerThread::take_local_job` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:751:19: 751:39
    = note: inside `rayon_core::registry::WorkerThread::wait_until_cold` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:785:32: 785:53
    = note: inside `rayon_core::registry::WorkerThread::wait_until::<rayon_core::latch::OnceLatch>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:769:13: 769:40
    = note: inside `rayon_core::registry::WorkerThread::wait_until_out_of_work` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:818:9: 818:65
    = note: inside `rayon_core::registry::main_loop` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:923:5: 923:43
    = note: inside `rayon_core::registry::ThreadBuilder::run` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:53:18: 53:33
    = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:98:20: 98:32
    = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154:18: 154:21
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:521:17: 521:71
    = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557:40: 557:43
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520:19: 520:88
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358:14: 358:33
    = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:520:30: 522:16
    = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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 C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
    = note: inside `std::sys::pal::windows::thread::Thread::new::thread_start` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\windows\thread.rs:55:22: 55:69

warning: integer-to-pointer cast
    --> C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1345:9
     |
1345 |         raw as *const _
     |         ^^^^^^^^^^^^^^^ integer-to-pointer cast
     |
     = note: BACKTRACE on thread `unnamed-1`:
     = note: inside `crossbeam_epoch::atomic::Shared::<'_, crossbeam_epoch::internal::Local>::as_raw` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\atomic.rs:1345:9: 1345:24
     = note: inside `crossbeam_epoch::internal::Local::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\internal.rs:332:24: 332:38
     = note: inside `crossbeam_epoch::collector::Collector::register` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\collector.rs:45:9: 45:30
     = note: inside `crossbeam_epoch::default::HANDLE::__init` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:34:34: 34:56
     = note: inside `<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init} as std::ops::FnOnce<()>>::call_once - shim(fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init})` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
     = note: inside `std::option::Option::<crossbeam_epoch::collector::LocalHandle>::unwrap_or_else::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:1014:21: 1014:24
     = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::initialize::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:64:17: 64:59
     = note: inside `std::thread::local_impl::LazyStorage::<crossbeam_epoch::collector::LocalHandle, ()>::get_or_init::<fn() -> crossbeam_epoch::collector::LocalHandle {crossbeam_epoch::default::HANDLE::__init}>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\lazy.rs:56:40: 56:61
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\thread_local\native\mod.rs:93:25: 93:54
     = note: inside `<{closure@crossbeam_epoch::default::HANDLE::{constant#0}::{closure#0}} as std::ops::FnOnce<(std::option::Option<&mut std::option::Option<crossbeam_epoch::collector::LocalHandle>>,)>>::call_once - shim` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250:5: 250:71
     = note: inside `std::thread::LocalKey::<crossbeam_epoch::collector::LocalHandle>::try_with::<{closure@crossbeam_epoch::default::with_handle<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>::{closure#0}}, bool>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:282:37: 282:55
     = note: inside `crossbeam_epoch::default::with_handle::<{closure@crossbeam_epoch::default::is_pinned::{closure#0}}, bool>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:59:5: 60:28
     = note: inside `crossbeam_epoch::default::is_pinned` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-epoch-0.9.18\src\default.rs:46:5: 46:45
     = note: inside `crossbeam_deque::deque::Stealer::<rayon_core::job::JobRef>::steal` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\crossbeam-deque-0.8.5\src\deque.rs:641:12: 641:30
     = note: inside `rayon_core::registry::WorkerThread::take_local_job` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:751:19: 751:39
     = note: inside `rayon_core::registry::WorkerThread::wait_until_cold` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:785:32: 785:53
     = note: inside `rayon_core::registry::WorkerThread::wait_until::<rayon_core::latch::OnceLatch>` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:769:13: 769:40
     = note: inside `rayon_core::registry::WorkerThread::wait_until_out_of_work` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:818:9: 818:65
     = note: inside `rayon_core::registry::main_loop` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:923:5: 923:43
     = note: inside `rayon_core::registry::ThreadBuilder::run` at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:53:18: 53:33
     = note: inside closure at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:98:20: 98:32
     = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<{closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154:18: 154:21
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:521:17: 521:71
     = note: inside `<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557:40: 557:43
     = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520:19: 520:88
     = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}::{closure#0}}>, ()>` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358:14: 358:33
     = note: inside closure at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:520:30: 522:16
     = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, {closure@<rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{closure#0}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\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 C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
     = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:2454:9: 2454:52
     = note: inside `std::sys::pal::windows::thread::Thread::new::thread_start` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\windows\thread.rs:55:22: 55:69

error: Undefined Behavior: incorrect layout on deallocation: alloc104484 has size 256 and alignment 64, but gave size 256 and alignment 8
   --> C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\raw_vec.rs:738:17
    |
738 |                 self.alloc.deallocate(ptr, layout);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: alloc104484 has size 256 and alignment 64, but gave size 256 and alignment 8
    |
    = 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 `alloc::raw_vec::RawVecInner::deallocate` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\raw_vec.rs:738:17: 738:51
    = note: inside `<alloc::raw_vec::RawVec<f64> as std::ops::Drop>::drop` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\raw_vec.rs:396:18: 396:50
    = note: inside `std::ptr::drop_in_place::<alloc::raw_vec::RawVec<f64>> - shim(Some(alloc::raw_vec::RawVec<f64>))` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ptr\mod.rs:574:1: 574:56
    = note: inside `std::ptr::drop_in_place::<std::vec::Vec<f64>> - shim(Some(std::vec::Vec<f64>))` at C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ptr\mod.rs:574:1: 574:56
note: inside `kmeans::variants::lloyd::Lloyd::<f64, 8>::update_centroids`
   --> C:\Users\<user>\Documents\dev\kmean-rs\src\variants\lloyd.rs:118:5
    |
118 |     }
    |     ^
note: inside `kmeans::variants::lloyd::Lloyd::<f64, 8>::calculate::<for<'a, 'b, 'c, 'd> fn(&'a kmeans::KMeans<f64, 8>, &'b mut kmeans::KMeansState<f64>, &'c kmeans::KMeansConfig<'d, f64>) {kmeans::KMeans::<f64, 8>::init_kmeanplusplus}>`
   --> C:\Users\<user>\Documents\dev\kmean-rs\src\variants\lloyd.rs:137:31
    |
137 |             let new_distsum = Self::update_centroids(data, &mut state);
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `kmeans::KMeans::<f64, 8>::kmeans_lloyd::<for<'a, 'b, 'c, 'd> fn(&'a kmeans::KMeans<f64, 8>, &'b mut kmeans::KMeansState<f64>, &'c kmeans::KMeansConfig<'d, f64>) {kmeans::KMeans::<f64, 8>::init_kmeanplusplus}>`
   --> C:\Users\<user>\Documents\dev\kmean-rs\src\api.rs:317:9
    |
317 |         crate::variants::Lloyd::calculate(self, k, max_iter, init, config)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `main`
   --> examples/lloyd.rs:12:18
    |
12  |     let result = kmean.kmeans_lloyd(k, max_iter, KMeans::init_kmeanplusplus, &KMeansConfig::default());
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

error: aborting due to 1 previous error; 2 warnings emitted

error: process didn't exit successfully: `C:\Users\<user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo-miri.exe runner target\miri\x86_64-pc-windows-msvc\debug\examples\lloyd.exe` (exit code: 1)

@seijikun
Copy link
Owner

This was a known bug in the crossbeam crate, that is fixed on their master-branch. The fix has not been released yet, so you will have to fix it by pinning crossbeam to master.

Can you try running it again with the following workaround in your Cargo.toml please?

[patch.crates-io]
crossbeam = { git = "https://github.com/crossbeam-rs/crossbeam.git" }
crossbeam-epoch = { git = "https://github.com/crossbeam-rs/crossbeam.git" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants