Commit Graph

18 Commits

Author SHA1 Message Date
Feoramund
efba9a1fb7 Disable usage of AddressSanitizer pending a per-allocator review
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
2025-06-15 15:06:28 -04:00
Laytan Laats
0ed6cdc98e mem/tlsf: fix asan reporting poisoning of already poisoned region
free on tlsf poisons the entire block, while alloc might only unpoison a
part of it (cause it's size is aligned up). This causes free to
potentially poison an already poisoned portion, which is a
use-after-poison.

Because this is "fine" and intended, I opted to just
@no_sanitize_address it.
2025-06-12 19:37:24 +02:00
Jeroen van Rijn
655fab7227 Add core/hyperthread count for Windows and Linux (#5216)
Add core/hyperthread count to `core:sys/info` for Windows and Linux.
TODO: Linux RISCV, Linux ARM, Darwin, and the BSDs.
2025-05-25 19:43:10 +02:00
Lucas Perlind
83bc2d3c4a Add asan support for various allocators 2025-05-06 14:55:50 +10:00
Jeroen van Rijn
0fc141db5d core:mem/tlsf: Add early-out in OOM logic
This implementation doesn't allow for out-of-band allocations to be passed through, as it's not designed to
track those. Nor is it able to signal those allocations then need to be freed on the backing allocator,
as opposed to regular allocations handled for you when you `destroy` the TLSF instance.

So if we're asked for more than we're configured to grow by, we can fail with an OOM error early, without adding a new pool.
2025-04-14 20:40:05 +02:00
Jeroen van Rijn
3d13beb3ec Remove now-implemented TODO 2025-04-14 20:09:55 +02:00
Jeroen van Rijn
beee27dec0 Allow core:mem/tlsf to automatically add new pools.
New features:
- If TLSF can't service an allocation made on it, and it's initialized with `new_pool_size` > 0, it will ask the backing allocator for additional memory.

- `estimate_pool_size` can tell you what size your initial (and `new_pool_size`) ought to be if you want to make `count` allocations of `size` and `alignment`, or in its other form, how much backing memory is needed for `count` allocations of `type` and its corresponding size and alignment.
2025-04-14 19:49:55 +02:00
Jeroen van Rijn
7088284ff4 Refactor core:mem/tlsf, add free_all support.
TODO: Allow the TLSF allocator to add additional pools when it would ordinarily OOM
      by calling its backing allocator.
2025-04-14 17:13:27 +02:00
Jeroen van Rijn
0e9cd0fb6a Prepare for tlsf.free_all 2025-04-13 15:20:53 +02:00
Lucas Perlind
88a5817134 Fix tlsf block adjustment 2025-02-10 13:01:16 +11:00
Laytan Laats
2d8d0dd851 fix @(optimization_mode) usage in builtin collections 2024-07-08 21:07:53 +02:00
gingerBill
e296d6fb90 Fix loads of indentation issues with mixing spaces and tabs 2024-06-29 19:50:51 +01:00
Laytan Laats
1c199f52d6 tlsf: destroy first pool & properly zero memory 2024-06-27 19:27:07 +02:00
Jeroen van Rijn
28ea9425fd Add core:mem tests. 2024-06-06 14:59:19 +02:00
Jeroen van Rijn
72f6b5479d Fix fls_uint 2024-06-06 14:42:19 +02:00
Jeroen van Rijn
0b6d73c86e Add original LICENSE 2024-06-06 14:29:28 +02:00
gingerBill
fac9ce5d83 Change to init from create 2024-06-05 15:30:35 +01:00
gingerBill
d3342c2381 core:mem/tlsf - "Two-Level Segregated Fit" memory allocator 2024-06-05 15:15:39 +01:00