Repository navigation
Conversation
Calling cugraph_sssp or cugraph_biased_random_walks on a graph created through the C API without a weight array segfaults. pylibcugraph.sssp and pylibcugraph.biased_random_walks reach the same crash because they call these functions directly. When no weights are passed, the graph creation code in cpp/src/c_api/graph_sg.cpp (lines 590-600) leaves edge_weights_ as nullptr. The sssp_functor in cpp/src/c_api/sssp.cpp reads that pointer at lines 72-73 and dereferences it unconditionally at line 105 (edge_weights->view()). The biased_random_walks_functor in cpp/src/c_api/random_walks.cpp does the same at line 215. The uniform and node2vec functors in the same file already handle a null pointer by passing std::nullopt. The Python cugraph.sssp wrapper (python/cugraph/cugraph/traversal/sssp.py lines 188-193) already rejects unweighted graphs with a RuntimeError that points the caller to BFS, and the C++ cugraph::sssp and cugraph::biased_random_walks APIs take a required weight view. The C API had no matching check. Both functors now return CUGRAPH_INVALID_INPUT with an error message through mark_error when the graph has no edge weights, matching the existing input checks in bfs.cpp and neighbor_sample.cpp. The Doxygen comments for cugraph_sssp and cugraph_biased_random_walks state the requirement. New C API tests test_sssp_unweighted (sssp_test.c) and test_biased_random_walks_unweighted (sg_random_walks_test.c) build a graph with a NULL weight array and check that the call returns CUGRAPH_INVALID_INPUT, leaves the result NULL and sets a non-empty error message. Both tests segfault without this change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6 of 11 tasks
Collaborator
|
/ok to test 38d38c2 |
Contributor
Author
|
@ChuckHastings thanks for triggering the CI run earlier. In the previous run on I merged the latest |
ChuckHastings
approved these changes
Dec 1, 2026
Collaborator
|
@morristai - If you can merge with the latest code I will trigger a rerun and try and get this merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5716
A graph created without a weight array has
edge_weights_ == nullptr, and the SSSP and biased random walk functors dereferenced it. Both now returnCUGRAPH_INVALID_INPUTthroughmark_errorbeforetranspose_storage, following the input checks inbfs.cppandneighbor_sample.cpp. The Doxygen comments forcugraph_ssspandcugraph_biased_random_walksnow say that the graph must have edge weights.Rejecting the input matches the Python
cugraph.ssspwrapper and the C++cugraph::ssspsignature, which takes a required weight view. If you would rather have the C API treat missing weights as 1.0, I can change it.New tests
test_sssp_unweightedandtest_biased_random_walks_unweightedbuild graphs with a NULL weight array and check the return code, the null result and the error message.🤖 Generated with Claude Code