get_all_neighbors (and others) cause segmentation fault instead of error when called with nonexistant vertex
When calling Graph.get_all_neighbors
on a graph instance and passing an index to a non-existent vertex, it causes a segmentation fault where raising a python exception would be more appropriate.
Example leading to segmentation fault:
import graph_tool as gt
g = gt.Graph() # same result if directed=True
g.get_all_edges(0)
produces
Segmentation fault (core dumped)
Curiously, if Graph.vertex
is called on the instance first, then it no longer prints as if it were segfaulting but perhaps still is.
Example leading to possible silent segmentation fault:
import graph_tool as gt
g = gt.Graph()
print("get first vertex")
g.vertex(0)
print("get first vertex edges")
g.get_all_edges(0)
produces
get first vertex
Traceback (most recent call last):
File "vargas_island/tests/graph_tool_error.py", line 5, in <module>
g.vertex(0)
File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2000, in vertex
raise ValueError("Invalid vertex index: %d" % int(i))
ValueError: Invalid vertex index: 0
Notice the lack of output from print("get first vertex edges")
, so perhaps Graph.vertex
raises a python error and then still causing a fault. I also tried replacing get_all_neighbors
with get_all_edges
to the same result, so it is likely a more widespread issue.
Environment
I'm using graph-tool installed through apt
python3-graph-tool/focal,now 2.59 amd64 [installed]
in a docker containers running Ubuntu 20.04:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
with python 3.8
Python 3.8.10