Skip to content

rayon crashes #1381

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

Closed
bjorn3 opened this issue Jun 23, 2023 · 4 comments
Closed

rayon crashes #1381

bjorn3 opened this issue Jun 23, 2023 · 4 comments
Labels
C-bug Category: This is a bug. upstream Caused by a dependency

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jun 23, 2023

https://github.com/xiph/rav1e

All of them are like

---- api::test::output_frameno_incremental_reorder_scene_change_at_3 stdout ----
---- api::test::output_frameno_incremental_reorder_scene_change_at_3 stderr ----
thread '<unnamed>' panicked at 'index out of bounds: the len is 140710327231184 but the index is 128', /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:541:24
stack backtrace:
   0: rust_begin_unwind
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_bounds_check
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panic.rs:61:9
   3: rayon_core::registry::Registry::in_worker_cold::{{closure}}::{{closure}}
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:541:24
   4: rayon_core::job::JobResult<T>::call::{{closure}}
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/job.rs:218:41
   5: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panic/unwind_safe.rs:265:9
   6: std::panicking::try::do_call
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:500:40
   7: std::panicking::try
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:464:19
   8: std::panic::catch_unwind
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panic.rs:142:14
   9: rayon_core::unwind::halt_unwinding
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/unwind.rs:17:5
  10: rayon_core::job::JobResult<T>::call
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/job.rs:217:5
  11: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/job.rs:120:32
  12: rayon_core::job::JobRef::execute
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/job.rs:64:9
  13: rayon_core::registry::WorkerThread::execute
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:874:9
  14: rayon_core::registry::WorkerThread::wait_until_cold
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:820:17
  15: rayon_core::registry::WorkerThread::wait_until
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:803:13
  16: rayon_core::registry::main_loop
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:948:5
  17: rayon_core::registry::ThreadBuilder::run
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:54:18
  18: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}
             at /home/gh-bjorn3/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.11.0/src/registry.rs:99:20
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@bjorn3 bjorn3 added the C-bug Category: This is a bug. label Jun 23, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Jul 12, 2023

The same crash happens with wasmtime. Running rayons test suite also results in this error.

@bjorn3 bjorn3 changed the title rav1e test suite failures rayon crashes Jul 12, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Jul 12, 2023

Looks like cg_clif accidentally used PanicBoundsCheck for AssertKind::MisalignedPointerDereference causing a wrong panic message. The correct panic message is:

thread '<unnamed>' panicked at 'misaligned pointer dereference: address must be a multiple of 0x80 but is 0x7f29244ed1c0', /home/gh-bjorn3/cg_clif/rayon/rayon-core/src/registry.rs:523:24
stack backtrace:
   0: rust_begin_unwind
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_nounwind_fmt
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panicking.rs:96:14
   2: core::panicking::panic_misaligned_pointer_dereference
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panicking.rs:175:5
   3: rayon_core::registry::Registry::in_worker_cold::{{closure}}::{{closure}}
             at ./rayon-core/src/registry.rs:523:24
   4: rayon_core::job::JobResult<T>::call::{{closure}}
             at ./rayon-core/src/job.rs:218:41
   5: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/core/src/panic/unwind_safe.rs:265:9
   6: std::panicking::try::do_call
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:500:40
   7: std::panicking::try
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panicking.rs:464:19
   8: std::panic::catch_unwind
             at /home/gh-bjorn3/cg_clif/build/stdlib/library/std/src/panic.rs:142:14
   9: rayon_core::unwind::halt_unwinding
             at ./rayon-core/src/unwind.rs:17:5
  10: rayon_core::job::JobResult<T>::call
             at ./rayon-core/src/job.rs:218:15
  11: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute
             at ./rayon-core/src/job.rs:120:32
  12: rayon_core::job::JobRef::execute
             at ./rayon-core/src/job.rs:64:9
  13: rayon_core::registry::WorkerThread::execute
             at ./rayon-core/src/registry.rs:855:9
  14: rayon_core::registry::WorkerThread::wait_until_cold
             at ./rayon-core/src/registry.rs:802:21
  15: rayon_core::registry::WorkerThread::wait_until
             at ./rayon-core/src/registry.rs:777:13
  16: rayon_core::registry::main_loop
             at ./rayon-core/src/registry.rs:926:5
  17: rayon_core::registry::ThreadBuilder::run
             at ./rayon-core/src/registry.rs:54:18
  18: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}
             at ./rayon-core/src/registry.rs:99:20

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 12, 2023

Looks like WorkerThread is stack allocated and aligned to the cacheline size. Cranelift doesn't support aligning stack values to more than 16 bytes yet. If I heap allocate WorkerThread all tests pass except for a single test which requires panic=unwind.

Edit: Opened bytecodealliance/wasmtime#6716

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 22, 2023

Fixed in 55380a5. The entire rayon test suite now passes with the exception of a single test which tests the behavior of rayon when user code panics as cg_clif doesn't yet support unwinding on panics. In addition the entire test suite of rav1e passes on aarch64, but on x86_64 it requires _mm_avg_epu16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. upstream Caused by a dependency
Projects
None yet
Development

No branches or pull requests

1 participant