| > What little I know of Ada indicates that it doesn't actually solve the problem because it doesn't have safe dynamic memory allocation. It does, just not the way most are used to it. Surely if one wants to code like malloc()/free(), free() is unsafe in Ada and requires the Ada version of unsafe {} However many type constructions in Ada do dynamic allocation by themselves, including on the stack. If memory allocation fails, an exception is thrown and a retry with less memory requirements is a possible execution path. Ada also has RAII since Ada95 (controlled types), and yes SPARK formal specification now allows for ownership rules. |
So, since we're talking about the Linux kernel, that's a red flag straight away. Notice a whole section of this new LKML post is about their implementation of Rust's alloc crate? Linus doesn't want useless exceptions here and has previously objected on that basis.
Meanwhile... Over in the C++ world they have this same behaviour. For them these exception handlers are a fiction, in reality popular standard libraries (never mind everything else you're using) will blow up in low memory and it's game over. Maybe Ada does a lot better. Maybe.