Commit 2f4e574
chenshengxin2026
Fix: two ring-buffer allocator defects in pto_ring_buffer.h
Bug 1 — Heap wrap-around: change strict `>` to `>=` in try_bump_heap.
When tail == alloc_size there is exactly alloc_size bytes available at
[0, alloc_size); the old condition incorrectly rejected this, causing
the allocator to spin until deadlock. Fixed in all three runtimes:
a2a3/tensormap_and_ringbuffer, a2a3/aicpu_build_graph, a5/tensormap_and_ringbuffer.
Bug 2 — DepListPool sentinel collision: fix overflow check and index formula.
`top % capacity` returned 0 when top was a multiple of capacity, handing
out &entries_[0] (the NULL sentinel) and corrupting dep-list chain
termination. Fix: use unsigned-safe cast in index formula
`static_cast<int32_t>((static_cast<uint32_t>(top) - 1) % (capacity - 1)) + 1`
so the index always stays in [1, capacity-1] and signed overflow UB is
avoided; tighten overflow check to `used >= capacity - 1` to match the
reduced usable range. Applied to all three runtimes.
Additionally:
- Add copyright headers to the three pto_ring_buffer.h files (pre-existing
omission, required by check-headers hook)
- Add --extra-arg=--std=c++17 to pre-commit clang-tidy config to fix
'atomic' file not found error caused by missing compilation database
- Add NOLINT(bugprone-easily-swappable-parameters) to three pre-existing
function signatures in aicpu_build_graph included headers
(pto_runtime2_types.h, pto_submit_types.h, tensor.h)
- Apply clang-format to all modified files
Fixes #4291 parent 13bf816 commit 2f4e574
3 files changed
Lines changed: 9 additions & 9 deletions
File tree
- src
- a2a3/runtime
- aicpu_build_graph/runtime
- tensormap_and_ringbuffer/runtime
- a5/runtime/tensormap_and_ringbuffer/runtime
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
| 566 | + | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | | - | |
| 447 | + | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | | - | |
| 447 | + | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| |||
0 commit comments