Segmentation fault inside cuptiPCSamplingGetData() in continuous PC Sampling mode

We are using CUPTI PC Sampling in a PyTorch distributed training job on NVIDIA H200 GPUs. The injector runs inside the training process, but the sampling logic is intended to be a passive diagnostic component.

Configuration:

  • CUDA 13.0
  • collection-mode = 1 (continuous)
  • sampling period = 17
  • data retrieval interval = 1000 ms
  • host-side record buffer capacity = 500
  • multiple distributed processes and NCCL activity
  • cuptiPCSamplingGetData() is called only from a dedicated background thread
  • CUDA kernel-launch and module-load callbacks do not call any PC Sampling API

The process eventually crashes with a segmentation fault inside CUPTI:

__strlen_evex
__GI___strdup
cuptiPCSamplingGetData
GetPcSamplingDataFromCupti
PeriodicDrainThread

The crash happens inside the CUPTI call, before it returns an error code. The application does not receive CUPTI_ERROR_*; instead, the training process receives SIGSEGV.

Immediately before the crash, our diagnostics show that the input structure and output buffer are valid:

params_size = 32
data_size = 80
capacity = 500
total_samples = 977
total_pcs = 500
remainingNumPcs ≈ 55,000
hardware_buffer_full = 0

The returned PC records contain valid addresses and readable function names. In some runs, an LD_PRELOAD tracer shows that CUPTI calls strdup() with readable strings such as spin_kernel, load_kernel, and store_kernel. In other runs, no invalid caller-side pointer can be observed.

The large remainingNumPcs value indicates that the producer is generating data faster than the application retrieves it, but we do not know whether this is merely a backlog/stress condition or whether it can expose an internal CUPTI bug. A robust API would normally report overflow or an error rather than dereference an invalid pointer and crash the host process.

The crash often occurs near NCCL initialization or dynamic CUDA module activity. We would like to clarify:

  1. Is it supported to call cuptiPCSamplingGetData() periodically from a background thread while CUDA kernels and NCCL/JIT modules are concurrently loading or unloading?
  2. In continuous mode, must PC Sampling data be retrieved or synchronized at every module load/unload boundary?
  3. Can a large remainingNumPcs value cause CUPTI internal metadata corruption or an unrecoverable condition?
  4. Are there known CUDA 13.0/CUPTI 13 issues involving cuptiPCSamplingGetData(), strdup(), or function-name resolution?
  5. Is there a recommended buffer size or retrieval protocol for preventing this condition?
  6. Is there a supported way to use PC Sampling from an external process so that a CUPTI failure cannot terminate the training process?

We can provide the complete CUPTI initialization code, the exact CUpti_PCSamplingGetDataParams contents, and full per-process forensic logs if needed.

Thanks for reporting it, we are looking into it internally, if needed we might ask for reproducer.

Follow-up: direct gdb evidence

We reproduced the crash again with the same CUDA 13.0 continuous PC Sampling configuration on a 4-node H200 training job.

Relevant caller code:

CUpti_PCSamplingGetDataParams params = {};
params.size = CUpti_PCSamplingGetDataParamsSize;
params.pPriv = NULL;
params.ctx = context;
params.pcSamplingData = pPcSamplingData;
cuptiPCSamplingGetData(&params);

Native stack:

__strlen_evex
__GI___strdup
cuptiPCSamplingGetData
GetPcSamplingDataFromCupti
PeriodicDrainThread

Full gdb backtrace:

#0 __strlen_evex
#1 __GI___strdup (s=0x0)
#2-#4 internal frames in libcupti.so.13
#5 cuptiPCSamplingGetData()
#6 GetPcSamplingDataFromCupti(…)
#7 PeriodicDrainThread()

Registers:

RIP = 0x7f311665795c (__strlen_evex+28)
RSP = 0x7f2d78e4eab8
RDI = 0x0
RSI = 0x0
RDX = 0x75
RAX = 0x0

The decisive evidence is that libcupti internally calls
strdup(s=0x0), and strlen receives RDI=0. Address 0 is unmapped in the
saved process mappings. The loaded CUPTI binary was:

libcupti.so.2025.3.1

This might indicate a NULL string dereference inside the CUPTI
cuptiPCSamplingGetData() path, before the API returns an error code? QAQ

Can we get a minimal reproducer for the crash, we are not able to repro it locally.
To answer your question regarding if CUPTI does strdup inside cuptiPcSamplingGetData(), yes we do for the each new function name, which passed as out parameter in CUpti_PCSamplingPCData. We don’t expect a scenario where we would be doing memory allocation for null function name. So having a reproducer will help us catch the crash issue.