Skip to content

Commit 37efc09

Browse files
authored
use a meaningful kernel to directly read the faulty kernel name (#130)
Signed-off-by: youkaichao <[email protected]>
1 parent 88b127d commit 37efc09

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

_posts/2025-08-11-cuda-debugging.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ __global__ void illegalMemoryAccessKernel(int* data, int size) {
9292
// This will cause illegal memory access - accessing beyond allocated memory
9393
// We allocate 'size' elements but access up to size * 2
9494
if (idx < size * 2) { // Access twice the allocated size
95-
data[idx - 1000000000] = idx; // This will cause illegal access for idx == 0
95+
for (int i = 0; i < 10000; i++) {
96+
data[idx - 1000000000 + i] = idx; // This will cause illegal access for idx == 0
97+
}
9698
}
9799
}
98100

@@ -156,14 +158,13 @@ This code launches two kernels consecutively (`illegalMemoryAccessKernel` and `n
156158
By adding the CUDA core dump-related environment variables, we can observe:
157159
158160
```text
159-
[00:40:46.606413] coredump: SM 123/132 has finished state collection
160-
[00:40:46.606419] coredump: SM 124/132 has finished state collection
161-
[00:40:46.611453] coredump: Detected an exception of type CUDBG_EXCEPTION_WARP_ILLEGAL_ADDRESS (14)
162-
[00:40:46.611458] coredump: - Device: 0
163-
[00:40:46.611460] coredump: - SM: 124
164-
[00:40:46.611462] coredump: - Warp: exception was detected after the warp has exited
165-
[00:40:46.611465] coredump: - PC 0x7f31abb9f6d0
166-
[00:40:46.611467] coredump: SM 125/132 has finished state collection
161+
[06:43:15.209195] coredump: Detected an exception of type CUDBG_EXCEPTION_WARP_ILLEGAL_ADDRESS (14)
162+
[06:43:15.209202] coredump: - Device: 0
163+
[06:43:15.209206] coredump: - SM: 124
164+
[06:43:15.209208] coredump: - Warp: 0
165+
[06:43:15.209210] coredump: - PC 0x7462c3bac310
166+
[06:43:15.209477] coredump: Stack trace (lane masks: active 0xFFFFFFFF, valid 0xFFFFFFFF):
167+
[06:43:15.209486] coredump: #0 0x7462c3bac620 _Z25illegalMemoryAccessKernelPii
167168
168169
[00:40:46.806153] coredump: Writing ELF file to /tmp/cuda_coredump_xxx.1799919.1754898045
169170

0 commit comments

Comments
 (0)