Repository navigation
Commit e66df63
Fix memory tagging, heap profiler, aligned allocation, and interface bugs
Memory tagging: fix the tag verification comparison which never
matched a valid tag, fix the whole zone tag refresh condition and
write through the unmasked user pages pointer, reject one-past-the-end
pointers, and use modulo for the chunk offset check since chunk sizes
are not always a power of 2. Freed chunks now always receive a tag
that differs from the previous one so a stale tagged pointer can never
verify.
Heap profiler: size the zone profiler map for SMALL_SIZE_MAX inclusive,
copy the full trace arrays, compute usage percentages with float math,
check dladdr results, and call the free profiler under the root lock.
Walk frame pointers directly for backtraces since gcc returns 0 for
__builtin_return_address(n > 0) on aarch64. Declare profiler globals
extern in the header so the profiler links under -fno-common.
Aligned allocation: posix_memalign, memalign, aligned_alloc, and the
aligned C++ new operators now honor the requested alignment through
_iso_alloc_aligned. Alignments up to a page come from an exact fit
zone, larger ones from an over-mapped and trimmed big zone. Hooks
validate alignment per POSIX. Throwing operator new retries via the
new handler and throws bad_alloc rather than returning NULL.
Interfaces: iso_alloc_new_zone returns NULL instead of a masked NULL,
iso_zone_chunk_count handles a NULL handle.
Sanity: only check the sampled chunk canary when it was written.
Tests: add aligned_alloc_test to the test suite, aligned new coverage
to the C++ tests, valid_tag_ptr_test and tag_refresh_test to the
tagging suite, and a profiler_tests target with profiler_test.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>1 parent f55c8ca commit e66df63
19 files changed
Lines changed: 1212 additions & 149 deletions
File tree
- include
- src
- tests
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
425 | 429 | | |
426 | 430 | | |
427 | 431 | | |
| 432 | + | |
428 | 433 | | |
429 | 434 | | |
430 | 435 | | |
| |||
463 | 468 | | |
464 | 469 | | |
465 | 470 | | |
| 471 | + | |
| 472 | + | |
466 | 473 | | |
467 | 474 | | |
468 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
469 | 484 | | |
470 | 485 | | |
471 | 486 | | |
| |||
530 | 545 | | |
531 | 546 | | |
532 | 547 | | |
533 | | - | |
| 548 | + | |
534 | 549 | | |
535 | 550 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
370 | 374 | | |
371 | 375 | | |
372 | 376 | | |
| |||
377 | 381 | | |
378 | 382 | | |
379 | 383 | | |
| 384 | + | |
380 | 385 | | |
381 | 386 | | |
382 | 387 | | |
| |||
389 | 394 | | |
390 | 395 | | |
391 | 396 | | |
| 397 | + | |
392 | 398 | | |
393 | 399 | | |
394 | 400 | | |
| |||
414 | 420 | | |
415 | 421 | | |
416 | 422 | | |
417 | | - | |
| 423 | + | |
418 | 424 | | |
| 425 | + | |
419 | 426 | | |
420 | 427 | | |
421 | 428 | | |
| |||
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
433 | 443 | | |
434 | 444 | | |
435 | 445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | | - | |
38 | | - | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
43 | | - | |
| 46 | + | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
0 commit comments