1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

6 Commits

Author SHA1 Message Date
Benjamin Valentin
f731ec7bff sys/malloc_tracing: fix calloc printouts 2023-11-09 20:15:53 +01:00
Marian Buschsieweke
7ce641f110
sys/malloc_tracing: add module to trace dyn memory management
Hooking into the existing wrappers for `malloc()`, `calloc()`,
`realloc()`, and `free()`, the new (pseudo) module `malloc_tracing`
prints out the calls to the given functions, the program counter of
the caller, as well as the return result.

The intent is to aid debugging double-frees, invalid frees, or memory
leaks.
2022-11-15 12:59:46 +01:00
812b273845 sys/malloc_thread_safe: mark functions "used"
Fixes LTO.
2022-02-15 12:28:16 +01:00
Marian Buschsieweke
eefed0e0cd
sys/malloc_thread_safety: fix overflow in calloc
some standard c libraries (e.g. newlib before 4.0.0) don't perform
proper overflow check in the multiplication. We just implement calloc
here ourselves on top of malloc with proper overflow check in place.
This might even safe a handful of ROM bytes.
2021-05-06 13:04:01 +02:00
Marian Buschsieweke
c790e2eb6d
sys/malloc_thread_safety: use mutex
Disabling IRQs during malloc() provides mutually exclusive access and even is
safe from IRQ context, but is suboptimal for real time scenarios. Instead, the
implementation is changed to use a mutex to provide mutually exclusive access.

As a result, calls to malloc() and free() from IRQ context no longer is
possible. But this this is a really horrible idea to begin with, the impact
should be minimal and the improved real time properties of the system should
make it a good trade-off. An assert() is added to allow easy detection of
regressions and, hence, aid users to fix their code.
2020-12-17 15:39:05 +01:00
Marian Buschsieweke
902aa29b62
sys/malloc_thread_safe: split out of cpu/atmega_common
Split out Gunar Schorcht's clever approach to provide thread safe malloc for
AVR into a system module and make AVR depend on this. This allows other
platforms to also use this.
2020-12-17 15:39:05 +01:00