Commit 3199107
committed
fix(core): retain cuLinkCreate optionValues array for CUlinkState lifetime
The CUDA driver docs state: "optionValues must remain valid for the life
of the CUlinkState if output options are used." The driver writes log-
fill sizes (output) back into the optionValues slots for
CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES and CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES.
Linker_init previously declared c_jit_keys/c_jit_values as local
cdef vector[...] on the stack of Linker_init; they were destroyed when
the function returned, leaving the driver with dangling writes during
subsequent cuLinkAddData/cuLinkComplete/cuLinkDestroy calls.
This was always latent. It became reachable with the per-instance
backend dispatch (CTK 12.9.1 runners now select the driver linker when
they pair with a driver 13 install), and only manifested on driver 13
as heap corruption that killed the next NVRTC or link call.
Promote the two arrays to cdef class fields declared after
_culink_handle in the pxd. Cython's tp_dealloc destroys C++ fields in
pxd declaration order, so the vectors are destroyed after the shared_ptr
deleter runs cuLinkDestroy. The cuda.bindings high-level wrapper
(driver.cuLinkCreate) already handles this by attaching a keepalive to
CUlinkState; cuda.core's low-level cydriver.cuLinkCreate path did not.
Also drop the now-unused void_ptr ctypedef.1 parent c25f5f9 commit 3199107
2 files changed
+33
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
12 | 24 | | |
13 | 25 | | |
14 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
460 | 459 | | |
461 | 460 | | |
462 | 461 | | |
463 | | - | |
464 | | - | |
| 462 | + | |
| 463 | + | |
465 | 464 | | |
466 | 465 | | |
467 | 466 | | |
| |||
501 | 500 | | |
502 | 501 | | |
503 | 502 | | |
504 | | - | |
505 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
506 | 511 | | |
507 | | - | |
| 512 | + | |
508 | 513 | | |
509 | 514 | | |
510 | | - | |
| 515 | + | |
511 | 516 | | |
512 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
513 | 522 | | |
514 | 523 | | |
515 | 524 | | |
516 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
517 | 529 | | |
518 | 530 | | |
519 | 531 | | |
| |||
0 commit comments