Skip to content

Crash / integer underflow in Index Points node #3621

@0HyperCube

Description

@0HyperCube

Reproduce

  • New document
  • Open node graph
  • Create «Path node»
  • Connect output to «Index Points»
  • Connect output to the «Line» node (you must expose one of the inputs to the node graph by clicking on the circle)
  • Connect output to graph output
final node graph

Reproduction file: index_points_underflow.graphite.json (file -> open then remove any file extension filtering to see it)

Cause

The crash only occurs in debug mode:

frontend/wasm/src/lib.rs:45
Node graph evaluation panicked panicked at node-graph/nodes/vector/src/vector_nodes.rs:2283:30:
attempt to subtract with overflow

If index is >= 0 (as is default) and points_count is 0 then there is underflow

let points_count = content.iter().map(|row| row.element.point_domain.positions().len()).sum::<usize>();
// Clamp and allow negative indexing from the end
let index = index as isize;
let index = if index < 0 {
(points_count as isize + index).max(0) as usize
} else {
(index as usize).min(points_count - 1)
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    CrashA panic which crashed the editorGood First IssueGood for newcomers

    Type

    Projects

    Status

    Short-Term

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions