Add sanity check for add_edges and add_nodes
- Dominant language
- Python
- Stars
- 14.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
I call `g.remove_nodes()` to remove 1 node from certain graphs, and python crashes (or the ipython kernel dies).
My event logs show an exception code 0xc0000409, which according to [this](https://stackoverflow.com/a/49781951) is a STATUS_STACK_BUFFER_OVERRUN. I tracked down the error to a call to `_CAPI_DGLHeteroVertexSubgraph(self, vids)` here: https://github.com/dmlc/dgl/blob/8a07ab77376a99b7114d0850ff99331ed88a648e/python/dgl/heterograph_index.py#L803
The problem is *not* the size of the graphs, as I am able to create and remove nodes from much larger graphs than those causing this problem.
## To Reproduce
Steps to reproduce the behavior:
1. Generate a problematic graph. I uploaded one here: https://drive.google.com/file/d/1jUNZLx2O4Y3lemy8EVAgUP4Zy5MmyCkz/view?usp=sharing
2. `g = dgl.load_graphs("debug_graphs.bin")[0][0]`
3. `g.remove_nodes([torch.tensor(49)])`
Other methods like `graph.in_edges` seem to cause similar crashes.
If this is an issue with how `graph.remove_nodes` and other methods are implemented, that should be fixed.
If this is an issue with the structure of these graphs, dgl should identify these structural problems when adding a node or edge and throw an informative exception.
## Environment
- DGL Version (e.g., 1.0): .6
- Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): 1.7.0
- OS (e.g., Linux): Windows 10
- How you installed DGL (`conda`, `pip`, source): conda
- Build command you used (if compiling from source):
- Python version: 3.8
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.