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

Panic from ancestors and descendants #1381

Open
barakatzir opened this issue Feb 4, 2025 · 1 comment
Open

Panic from ancestors and descendants #1381

barakatzir opened this issue Feb 4, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@barakatzir
Copy link
Contributor

barakatzir commented Feb 4, 2025

Information

  • rustworkx version: currently on main (commit f2f45425c70b49d89aa5527271a34f64fb114f1d)
  • Python version: 3.12
  • Rust version: ...
  • Operating system: ubuntu

What is the current behavior?

When calling rustworkx.ancestors or rustworkx.descendants with index not in graph a PanicExpection is raised

I haven't checked, but I suspect that this bug is also present in rustworkx-core.

What is the expected behavior?

I expected either an IndexError or an empty set (similar to say predecessor_indices method that return an empty NodeIndices in similar situation).

Steps to reproduce the problem

# t.py

import rustworkx as rx

graph = rx.PyDiGraph()
graph.extend_from_edge_list([(0, 1), (2, 1), (3, 1), (1, 4)])
rx.ancestors(graph, 10)

When run python t.py I get

thread '<unnamed>' panicked at /home/barak-katzir/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fixedbitset-0.5.7/src/lib.rs:486:9:
put at index 10 exceeds fixedbitset size 5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/barak-katzir/dev/rustworkx-check/t.py", line 7, in <module>
    rx.descendants(graph, 10)
pyo3_runtime.PanicException: put at index 10 exceeds fixedbitset size 5

and similarly for rustworkx.descendants.

@IvanIsCoding
Copy link
Collaborator

I will send a patch tomorrow, I suspect we are missing an index check as you mentioned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants