sys/cpp_new_delete: handle allocation failures#22418
Conversation
If exceptions are supported, throw an `std::bad_alloc` on allocation failure. If not, panic on allocation failure.
Murdock results❌ FAILED 19abdf9 sys/cpp_new_delete: handle allocation failures Build failures (3)
Artifacts |
|
Tested with the Nucleo-G031K8 with the timer PR applied. It still crashes because after this I can't flash it before resetting/power cycling the microcontroller. |
|
I wonder if the hang is due to an uncaught exception (I see no code that would catch the bad alloc exception in either the It is good that there now is a defined crash, rather than the code keeping to run on corrupted memory. But the complete absense of any helpful indication of what went wrong in the log is a major footgun that I need to address first. |
|
Setting the Enabling DEVELHELP does not give additional information unfortunately. |
Contribution description
If exceptions are supported, throw an
std::bad_allocon allocation failure.If not, panic on allocation failure.
Testing procedure
Allocations should now fail as expected. E.g. the test in
tests/sys/cpp11_threadcan both easily trigger allocation failures and has a very interesting failure mode.With this fix, the failure mode should be more boring.
Issues/PRs references
Found in #22417
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: