feat(mem): OOM fault injection harness
Problem to solve
See #10119 . We want to be able to verify lv_malloc() == NULL handling at all call sites.
Success criteria
Migrate OOM detection to a test that can be run locally or maybe on CI if fast enough.
Catch the following crash when lv_malloc()==NULL:
char * p = lv_malloc(100);
strncpy(p, 100, "Goodbye World"But do not catch this one:
char * p = lv_malloc(100);
if(p){
strncpy(p, 100, "Goodbye World"
lv_free(p);
}Solution outline
Notes from Axos88:
The shim fork()s at each allocation. The parent gets the real pointer and carries on as normal, so it walks the full allocation sequence and forks once at every allocation point. The child gets NULL instead, marks itself as the injected-failure branch, and from then on the shim stops forking in that process and serves real allocations. Each child exercises exactly one failing allocation and then runs to completion. One pass over the test gives you N children for N allocations, instead of N full test runs — and stopping the forking in the child is what keeps it from blowing up to 2^N processes. fork() limits this to POSIX hosts, but that covers our CI.
Rabbit holes
Once up, this will expose many OOM crashes(hopefully all). We'll have to work through those.
Testing
The features is a test.
Teaching
For each run, this should explain the sites where it failed, perhaps with a backtrace.
Considerations
No response
Source: lvgl/lvgl