aboutsummaryrefslogtreecommitdiff
path: root/core/mem/allocators.odin
Commit message (Collapse)AuthorAgeFilesLines
* Fix indentationgingerBill2025-10-271-2/+2
|
* Fix out-of-band allocations in dynamic arenasrationalcoder2025-09-161-8/+8
|
* Add require_results attr to procs returning an allocatorDamian Tarnawski2025-09-021-0/+1
|
* Fix buddy allocator assertalessio988882025-08-161-1/+1
| | | | | | | The last address of "data" is not "cast(uintptr)raw_data(data)+cast(uintptr)size" but "cast(uintptr)raw_data(data)+cast(uintptr)(size-1)". The original assert would fail when for example the allocation size requested and the buddy allocator allignment were both 64.
* mem: Clarify `Buddy_Allocator` requirementsFeoramund2025-07-221-1/+4
|
* mem: Guard against `Buddy_Allocator` overwriting metadataFeoramund2025-06-201-0/+1
|
* mem: Don't print `Buddy_Allocator.tail`Feoramund2025-06-201-1/+1
| | | | | | This is always a pointer past the end of the buffer given to `buddy_allocator_init`, which could be an invalid address. Printing may result in a segmentation violation.
* mem: Forbid construction of `Buddy_Allocator` with insufficient spaceFeoramund2025-06-191-0/+1
| | | | This takes into account eventual alignment.
* mem: Fix `Buddy_Allocator` size calculation to truly include alignmentFeoramund2025-06-191-6/+8
| | | | | | | | | | | | | This didn't take into account the size of the header plus the size of the allocation itself by virtue of `align_forward_uint`; this could result in no change if `size` was equal to `b.alignment` because the number is aligned, and if `actual_size` and `size` ended up being equal, no additional space would be requested. This meant that a block would end up being allocated on top of its buddy's head. Fixes #3435
* mem: Fix inverted condition in `buddy_allocator_alloc_bytes_non_zeroed`Feoramund2025-06-191-1/+1
| | | | | This was causing the procedure to find a block, then find one again, or to not find a block and not try again.
* Disable usage of AddressSanitizer (pt. 2)Feoramund2025-06-151-4/+4
|
* Merge branch 'master' into fix-2694Feoramund2025-06-151-20/+56
|\
| * mem: compat allocator improvementsLaytan Laats2025-06-121-20/+56
| | | | | | | | | | | | | | | | | | 1. store alignment instead of original pointer 2. implement .Query_Info 3. poison the header and alignment portion of the allocation 4. .Resize uses `max(orig_alignment, new_alignment)` as it's alignment now 5. .Free passes along the original alignment
* | Disable usage of AddressSanitizer pending a per-allocator reviewFeoramund2025-06-151-59/+75
| | | | | | | | | | | | | | | | | | | | | | It has been discovered that AddressSanitizer does not keep a 1:1 mapping of which bytes are poisoned and which are not. This can cause issues for allocations less than 8 bytes and where addresses straddle 8-byte boundaries. See the following link for more information: https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm#mapping
* | mem: Standardize panic messagesFeoramund2025-06-151-14/+14
| |
* | mem: Review all documentation commentsFeoramund2025-06-151-129/+140
| |
* | mem: Poison memory for `Buddy_Allocator`Feoramund2025-06-151-7/+15
| |
* | mem: Guard against size 0 in `dynamic_arena_resize_*`Feoramund2025-06-151-0/+8
| |
* | mem: Poison memory for `Dynamic_Arena`Feoramund2025-06-151-0/+7
| |
* | mem: Make `dynamic_arena_alloc` not privateFeoramund2025-06-151-1/+1
| | | | | | | | | | None of the other `*_alloc` procs are private, and this proc is even referenced in public documentation comments.
* | mem: Remove bogus commentsFeoramund2025-06-151-12/+0
| | | | | | | | There is no `dynamic_arena_free`; the mode is not implemented
* | mem: Remove comment about calling `panic`Feoramund2025-06-151-1/+0
| | | | | | | | The behavior is codified in the comment as returning `Invalid_Pointer`.
* | mem: Remove trailing whitespaceFeoramund2025-06-151-1/+1
| |
* | mem: Panic when passing invalid pointers to small stack free/resizeFeoramund2025-06-151-4/+2
| | | | | | | | This is consistent with `Stack_Allocator`.
* | mem: Correct wrong error messageFeoramund2025-06-151-1/+1
| |
* | mem: Check if `alignment` matches on `Small_Stack` resizeFeoramund2025-06-151-0/+10
| |
* | mem: Make `small_stack_resize*` free if `size` is 0Feoramund2025-06-151-1/+1
| |
* | mem: Clarify what happens when you free out-of-order in a `Small_Stack`Feoramund2025-06-151-1/+4
| |
* | mem: Replace `auto_cast`Feoramund2025-06-151-1/+1
| |
* | mem: Don't unpoison the header of a `Small_Stack` allocationFeoramund2025-06-151-2/+4
| |
* | mem: Poison unused memory more thoroughlyFeoramund2025-06-141-0/+3
| |
* | mem: Check if `alignment` matches on `Stack_Allocator` resizeFeoramund2025-06-141-0/+10
| |
* | mem: Actually resize when resizing for `Stack_Allocator`Feoramund2025-06-141-2/+2
| | | | | | | | | | | | | | | | Changed the check from `bytes` to `err` for safety's sake, too. This will prevent the potential bug of allocating non-zero memory, then doing a zeroed resize, which will result in having garbage data in the initial half.
* | mem: Correct wrong error messageFeoramund2025-06-141-1/+1
| |
* | mem: Remove pointless check in `Scratch_Allocator`Feoramund2025-06-141-3/+0
| | | | | | | | | | The backup allocator is set at `init` which happens even if `Scratch` is nil at the head of `scratch_alloc_bytes_non_zeroed`.
* | mem: Don't change `Scratch_Allocator`'s backup allocatorFeoramund2025-06-141-4/+0
| | | | | | | | | | | | | | The backup allocator is set at `init` and must stay the same for the lifetime of the Scratch allocator, as this allocator is used to free all `leaked_allocations`. Changing it could lead to a situation where the wrong allocator is used to free a leaked allocation.
* | mem: Fix comment typoFeoramund2025-06-141-1/+1
| |
* | mem: Don't unpoison the header of a `Stack` allocationFeoramund2025-06-141-2/+1
| |
* | mem: Make `stack_resize*` free if `size` is 0Feoramund2025-06-141-1/+1
| | | | | | | | | | | | This will cause an error if the memory being resized was not the last allocation, as should be expected according to the description that this "acts just like stack_free."
* | mem: Add guards against buggy allocators overlapping allocationsFeoramund2025-06-141-1/+43
| |
* | mem: Fix several issues in `Scratch_Allocator`Feoramund2025-06-141-15/+42
|/ | | | | | | | | | | | | | | | | | | | 1. The size was being adjusted for the alignment which does not make any sense without the context of the base pointer. Now we just add the `alignment - 1` to the size if needed then adjust the pointer. 2. The root pointer of the last allocation is now stored in order to make the free operation more useful (and to cover the right memory region for ASan). 3. Resizing now only works on the last allocation instead of any address in a valid range, which resulted in overwriting allocations that had just been made. 4. `old_memory` is now re-poisoned entirely before the resized range is returned with the new range unpoisoned. This will guarantee that there are no unpoisoned gaps. Fixes #2694
* Add base:sanitizer packageLucas Perlind2025-04-241-22/+23
|
* Add more asan support to the odin runtime and begin sanitizingLucas Perlind2025-04-241-10/+42
| | | | | | | | | | | | | | | | | | | | | | allocators This adds various bindings to the asan runtime which can be used to poison/unpoison memory handed out by various allocators. This means we can catch use after free memory bugs when using operations such as free_all during runtime. Asan poisoning are added for the follow allocators in mem: Arena (including temporary arenas) Scratch Stack Small_Stack Additionally a bug in the stack allocator was fixed to disallow freeing in the middle of the stack (caught by the asan!). I plan on adding support for all the allocators in core. This is just a good starting point and were some of the easiest ones to implement asan for.
* General clean up of codegingerBill2025-01-011-23/+0
|
* Improve formattinggingerBill2024-10-111-167/+167
|
* Merge pull request #4208 from laytan/more-wasm-vendor-supportgingerBill2024-09-171-0/+78
|\ | | | | wasm: support more vendor libraries
| * wasm: support more vendor librariesLaytan Laats2024-09-091-0/+78
| | | | | | | | | | | | | | | | Adds support for: - box2d - cgltf - stb image - stb rect pack
* | [mem]: Adjust the docs on the buddy allocatorflysand72024-09-141-13/+192
| |
* | [mem]: Don't use named params for dynamic pool in testsflysand72024-09-081-8/+8
| |
* | [mem]: Start documenting allocators.odinflysand72024-09-081-73/+594
| |