Could we support unwinding from OOM, at least for collections?

I’m running x86_64, Ubuntu 14.04. malloc fails quite regularly for me. Rumours of overcommit seem greatly exaggerated.

SIGILL is easily generated by:

let b = vec![0;30 * 1024 * 1024 * 1024];

While, ideally, rust would expose fallible calls like malloc via Result<> types, those APIs look very far away.

I started porting an in-development C image processing server to Rust after hearing catch_unwind was stabilized. Then I discovered that the crowds were shouting for all OOM situations to abort instead of panic. I found this strange, as small mallocs will often succeed after large mallocs fail. And large mallocs are quite important to my use case - and my use case permits many strategies for backing off large malloc requests if they fail.

So while my current C code gracefully handles all allocation failures, I cannot seem to accomplish the same in Rust - and real problems arise quite quickly.

1 Like