Skip to content

[DO NOT MERGE] Reproduce flaky Rust parallel cargo test SIGSEGV - #2818

Closed
bdice wants to merge 8 commits into
NVIDIA:mainfrom
bdice:ci-repro-rust-parallel-segv
Closed

bdice wants to merge 8 commits into
NVIDIA:mainfrom
bdice:ci-repro-rust-parallel-segv

Conversation

@bdice

@bdice bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Reproduction PR for #2233 (Rust cargo test with default parallel test threads intermittently SIGSEGVs). Part of #2783.

CI-only changes:

  • pr.yaml reduced to conda-cpp-build (amd64, latest CUDA) and 4 copies of rust-build (2x rtxpro6000, 2x l4).
  • ci/stress_rust.sh loops the cuvs lib test binary with default, 8, 16, 32 and 64 test threads (some iterations under gdb), plus #[ignore]d multi-thread stress tests where each thread owns its own Resources, and a compute-sanitizer memcheck pass.

@copy-pr-bot

copy-pr-bot Bot commented Oct 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f4f7959

@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 72a1e10

@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 57efb6d

bdice added 4 commits October 11, 2026 00:40
The pinned host memory resource behind cuvsRMMHostAlloc/cuvsRMMHostFree
was a thread_local std::unique_ptr that was only created on the first
cuvsRMMHostAlloc call of each thread. Freeing a buffer on any other
thread dereferenced a null pointer. pinned_host_memory_resource is
stateless, so use a single process-wide instance instead.
adjust_centers() advanced a function-local static counter with a plain
read-modify-write. Concurrent builds (IVF-Flat, IVF-PQ, ...) from
several host threads, each with its own resources, raced on it.
@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d9e5779

@bdice

bdice commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this reproducer: the parallel cargo test SIGSEGV did not reproduce in 6,700 iterations, so no fix is needed here. The related bug it found is fixed in #2832; tracked in #2783.

@bdice bdice closed this Oct 15, 2026
rapids-bot Bot pushed a commit that referenced this pull request Nov 17, 2026
)

`cuvsRMMHostAlloc` and `cuvsRMMHostFree` used a `thread_local std::unique_ptr<rmm::mr::pinned_host_memory_resource>` that was created only on a thread's first `cuvsRMMHostAlloc` call. Freeing a buffer on any other thread, for example after a binding moves the owning object to another thread, dereferenced a null pointer. `pinned_host_memory_resource` is stateless, so this uses one process-wide instance instead.

The new `cuvs_c_host_alloc_test` frees a buffer on a different thread than the one that allocated it, and runs concurrent allocations and frees across 8 threads.

This was found while investigating the Rust parallel `cargo test` SIGSEGV in #2233, but it has not been shown to cause that report. The crash did not reproduce in about 6,700 parallel iterations (#2818). Part of #2783.

The same investigation found a data race on the function-local static prime counter in balanced k-means `adjust_centers()`. That counter is removed by #2804, so it is not changed here.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Victor Lafargue (https://github.com/viclafargue)
  - Divye Gala (https://github.com/divyegala)

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant