Skip to content

Fix append unique#423

Open
linhu-nv wants to merge 4 commits intorapidsai:mainfrom
linhu-nv:fix-append-unique
Open

Fix append unique#423
linhu-nv wants to merge 4 commits intorapidsai:mainfrom
linhu-nv:fix-append-unique

Conversation

@linhu-nv
Copy link
Contributor

@linhu-nv linhu-nv commented Mar 6, 2026

No description provided.

@linhu-nv linhu-nv requested review from a team as code owners March 6, 2026 05:32
@copy-pr-bot
Copy link

copy-pr-bot bot commented Mar 6, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@linhu-nv linhu-nv requested a review from alexbarghi-nv March 6, 2026 05:32
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR makes defensive null-check improvements to the WholeGraph bindings:

  • C++ fixes (append_unique.cpp, unweighted/weighted_sample_without_replacement.cpp): Adds null-guard checks for tensor and context pointers before dereferencing, preventing crashes on invalid inputs. The core graph_append_unique fix gates tensor description and data pointer access behind a != nullptr check.

  • Workflow change (.github/workflows/pr.yaml): Updates shared workflow references for wheel build and test jobs. The change to reference @python-3.14 instead of @main appears to be intentional for Python 3.14 compatibility testing.

The changes are safe for merging — no blocking issues identified.

Confidence Score: 5/5

  • Safe to merge — defensive null-check improvements across C++ and Python bindings address real edge cases without introducing new risks.
  • All C++ fixes correctly gate pointer dereferences behind null checks. The Python callback wrappers add consistent null validation. The workflow change to @python-3.14 appears intentional for platform testing. No blocking issues identified.
  • No files require special attention

Last reviewed commit: 18054d8

Comment on lines +427 to +429
if global_context == NULL:
(<void **> memory_context)[0] = NULL
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory_context is dereferenced at line 428 without first checking for null. When global_context == NULL, the code writes to memory_context[0] without validating memory_context itself is non-null. Every other callback in this PR (destroy, malloc, free, output_malloc, output_free) guards against null memory_context before dereferencing. This should be consistent:

Suggested change
if global_context == NULL:
(<void **> memory_context)[0] = NULL
return
if global_context == NULL:
if memory_context != NULL:
(<void **> memory_context)[0] = NULL
return

@gforsyth
Copy link
Contributor

gforsyth commented Mar 6, 2026

/ok to test 64d68c3

@gforsyth gforsyth requested a review from a team as a code owner March 6, 2026 18:40
@gforsyth gforsyth requested a review from bdice March 6, 2026 18:40
@gforsyth
Copy link
Contributor

gforsyth commented Mar 6, 2026

/ok to test 18054d8

@gforsyth
Copy link
Contributor

gforsyth commented Mar 6, 2026

Looks like this did fix the first round of segfaults. I added a 3.14 test job for pylibwholegraph so we can see the failure bubble up in this PR.

Currently:

 
Current thread's C stack trace (most recent call first):
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _Py_DumpStack+0x45 [0x77a03eb73805]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x312c6c [0x77a03eb89c6c]
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", at +0x45330 [0x77a03e6a3330]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at PyTuple_Size+0x8 [0x77a03ea193f8]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/pylibwholegraph/binding/wholememory_binding.abi3.so", at +0x420ad [0x77a03b4d80ad]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/pylibwholegraph/binding/wholememory_binding.abi3.so", at +0x27c19 [0x77a03b4bdc19]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyObject_MakeTpCall+0xc0 [0x77a03e97e080]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x10b0fa [0x77a03e9820fa]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/pylibwholegraph/binding/wholememory_binding.abi3.so", at +0x3be3a [0x77a03b4d1e3a]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/libwholegraph/lib64/libwholegraph.so", at _ZN14wholegraph_ops55wholegraph_csr_weighted_sample_without_replacement_funcIilfEEv18wholememory_gref_t31wholememory_array_description_tS1_S2_S1_S2_PvS2_iS3_S2_S3_S3_S3_yP22wholememory_env_func_tP11CUstream_st+0x137 [0x779fd7aa1717]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/libwholegraph/lib64/libwholegraph.so", at _ZN14wholegraph_ops57wholegraph_csr_weighted_sample_without_replacement_mappedE18wholememory_gref_t31wholememory_array_description_tS0_S1_S0_S1_PvS1_iS2_S1_S2_S2_S2_yP22wholememory_env_func_tP11CUstream_st+0x19b [0x779fd7a6d22b]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/libwholegraph/lib64/libwholegraph.so", at wholegraph_csr_weighted_sample_without_replacement+0x116d [0x779fd7a5d54d]
  Binary file "/pyenv/versions/3.14.3/lib/python3.14/site-packages/pylibwholegraph/binding/wholememory_binding.abi3.so", at +0x5c595 [0x77a03b4f2595]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyObject_MakeTpCall+0xc0 [0x77a03e97e080]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyEval_EvalFrameDefault+0x3f0f [0x77a03e914c1f]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x26b3ba [0x77a03eae23ba]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x109129 [0x77a03e980129]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x39281c [0x77a03ec0981c]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyObject_MakeTpCall+0xc0 [0x77a03e97e080]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at PyObject_Vectorcall+0x53 [0x77a03e97e2f3]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyEval_EvalFrameDefault+0x3f0f [0x77a03e914c1f]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x26b3ba [0x77a03eae23ba]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x108e6f [0x77a03e97fe6f]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x109060 [0x77a03e980060]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x1b9de4 [0x77a03ea30de4]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyObject_MakeTpCall+0xc0 [0x77a03e97e080]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at _PyEval_EvalFrameDefault+0x4e56 [0x77a03e915b66]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x26b3ba [0x77a03eae23ba]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x108e6f [0x77a03e97fe6f]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x109060 [0x77a03e980060]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at +0x1b9de4 [0x77a03ea30de4]
  Binary file "/pyenv/versions/3.14.3/lib/libpython3.14.so.1.0", at PyObject_Call+0xa4 [0x77a03e980384]
  <truncated rest of calls>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants