Memory allocation of 5290789082356236509 bytes failed

Hello, my rather complex rust program terminates with this message. Some runs last for multiple hours, sometimes I'm hitting this after 20 minutes. There is no stack trace (no matter if I run with RUST_BACKTRACE=1 or RUST_BACKTRACE=full), so I cannot narrow this down to a particular function. That's also the reason why I cannot share code. All I can say is that I'm not requesting this amount of memory of course.

I already put in extensive logging (e.g. printing sizes of maps and vectors), but there's notthing abnormal as far as I can tell. Any clues how I can narrow this down?

Thanks a lot
Martin

If you can run your program in a debugger it should break at the abort call that the OOM handler makes and you can get a backtrace from there.

Yeah, you can do this with gdb. First you run your program with gdb until it crashes. Then you can use the bt command, and it will tell you where it crashed.

I'm rather curious whether the number 5290789082356236509 is always the same or is it different each time? it might be a memory corruption instead of a true allocation failure, in which case you should check which unsafe code is unsound and caused a memory corruption.

because it aborts the process instead of panicking on allocation failure. you can use the unstable API set_alloc_error_hook, or replace the global allocator with a custom one so you can at least get a stack trace on oom situations to further diagnose the problem.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.