Stack overflow in `triu`

Open
#1,615 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
data

Research direction

Start by running the Rust example from the issue and then inspect the ArrayRef::triu entry point linked in the report. Verify that the transposed, inserted-axis view no longer overflows the stack, and add or update coverage for this case so the regression is prevented.

Written by the indexing model from the issue text.

Description

bug good first issue

The docs don't mention this as a hazard, so I figure it's a bug: https://docs.rs/ndarray/latest/ndarray/struct.ArrayRef.html#method.triu

use ndarray::{Array2, Axis};

fn main() {
    let a: Array2<f64> = Array2::from_shape_fn((3, 4), |(i, j)| (i * 4 + j) as f64);
    let ft = a.t();
    let widened = ft.insert_axis(Axis(2));
    widened.triu(0);
}

Found using a fuzzer.

Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.