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

Calls to __rust_probestack #2696

Open
KyleSiefring opened this issue Mar 19, 2021 · 0 comments
Open

Calls to __rust_probestack #2696

KyleSiefring opened this issue Mar 19, 2021 · 0 comments

Comments

@KyleSiefring
Copy link
Collaborator

For security reasons, large stack allocation result in some computations being done.
Thomas thought this was a bug on linux, but is doesn't seem to be. See rust discussion in rust-lang/rust#74405. See a previous commit solving this issue for interprediction: https://github.com/xiph/rav1e/pull/2429/files

These stack allocations occur in many places in the code. The ones that I can think of that I think are large enough to trigger probestack.

  • There are a set of arrays in encode_tx_block.

    rav1e/src/encoder.rs

    Lines 1184 to 1197 in d5df5b7

    let mut residual_storage: Aligned<[i16; 64 * 64]> = Aligned::uninitialized();
    let mut coeffs_storage: Aligned<[T::Coeff; 64 * 64]> =
    Aligned::uninitialized();
    let mut qcoeffs_storage: Aligned<[MaybeUninit<T::Coeff>; 32 * 32]> =
    Aligned::uninitialized();
    let mut rcoeffs_storage: Aligned<[T::Coeff; 32 * 32]> =
    Aligned::uninitialized();
    let residual = &mut residual_storage.data[..tx_size.area()];
    let coeffs = &mut coeffs_storage.data[..tx_size.area()];
    let qcoeffs = init_slice_repeat_mut(
    &mut qcoeffs_storage.data[..coded_tx_area],
    T::Coeff::cast_from(0),
    );
    let rcoeffs = &mut rcoeffs_storage.data[..coded_tx_area];
  • https://github.com/xiph/rav1e/blob/master/src/asm/x86/transform/forward.rs#L348
  • let mut copied: Aligned<[T::Coeff; 32 * 32]> = Aligned::uninitialized();

The first seems easiest to solve. The changes in this patch can be used as a template: https://github.com/xiph/rav1e/pull/2429/files

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

1 participant