Commit e0b46cb
committed
fix(core): two robustness fixes from roborev review
Roborev jobs #1770 and #1771:
* MEDIUM @ _program_cache.py:1235 -- ``__setitem__`` calls
``tempfile.mkstemp(dir=self._tmp)`` without ensuring ``tmp/`` still
exists. If something deletes it after ``__init__`` (operators
clearing by hand, another process's wipe), every subsequent write
crashes with FileNotFoundError even though we could trivially
recreate it. Fixed: ``self._tmp.mkdir(parents=True, exist_ok=True)``
before mkstemp -- same defensive recreation we already do for
``entries/<2-char>/`` shard subdirs.
* LOW @ _program.pyx:177 -- the uncached NVRTC path warns when the
active driver can't load freshly-generated PTX. Cache hits skipped
this warning, so ``Program.compile("ptx", cache=cache)`` could
silently hand back PTX that won't actually load on the active
driver. Loadability is a property of the driver, not of how the
bytes were produced -- mirror the warning before returning a
cached hit so cached and uncached calls behave the same on
loadability-vs-driver mismatches.
Tests added:
* ``test_filestream_cache_recreates_tmp_dir_if_missing`` --
``shutil.rmtree(root/"tmp")`` between two writes; the second write
must still succeed and recreate the dir.
* ``test_cache_hit_emits_ptx_loadability_warning_when_driver_too_old``
-- monkeypatch ``_can_load_generated_ptx`` to False on a preseeded
cache; cache hit must emit the RuntimeWarning.
* ``test_cache_hit_no_ptx_warning_when_driver_supports_it`` --
inverse: warning must NOT fire when the driver can load it.
Roborev #1770 also raised a MEDIUM about ``extra_sources`` being hashed
in caller-provided order. NVVM module linking is order-dependent in the
general case (overlapping symbols, weak definitions, etc.), so
canonicalizing the order would be unsound without proving the input
subset NVVM actually treats as order-insensitive. Keeping the
order-sensitive hash is the safer default; documented as part of
``_NvvmBackend.hash_extra_payload``'s comment in the strategy class.1 parent e08e89e commit e0b46cb
4 files changed
Lines changed: 91 additions & 0 deletions
File tree
- cuda_core
- cuda/core
- utils
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
178 | 195 | | |
179 | 196 | | |
180 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1513 | 1513 | | |
1514 | 1514 | | |
1515 | 1515 | | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
1516 | 1522 | | |
1517 | 1523 | | |
1518 | 1524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1576 | 1576 | | |
1577 | 1577 | | |
1578 | 1578 | | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
1579 | 1600 | | |
1580 | 1601 | | |
1581 | 1602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
119 | 166 | | |
120 | 167 | | |
121 | 168 | | |
| |||
0 commit comments