Commit 1572452
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 fe5a7b3 commit 1572452
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 | | |
| |||
508 | 507 | | |
509 | 508 | | |
510 | 509 | | |
511 | | - | |
512 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
513 | 518 | | |
514 | | - | |
| 519 | + | |
515 | 520 | | |
516 | 521 | | |
517 | | - | |
| 522 | + | |
518 | 523 | | |
519 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
520 | 529 | | |
521 | 530 | | |
522 | 531 | | |
523 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
524 | 536 | | |
525 | 537 | | |
526 | 538 | | |
| |||
0 commit comments