How does one detect whether a segfault is being caused by an out-of-memory condition?
I have a segfault that defies diagnosis by valgrind and duma/efence because it seems to crash those tools themselves (Valgrind “the impossibe happened”, duma: “mprotect() failed: Cannot allocate memory” )
The application (Gazebo) simply crashes with a segfault, and a stack trace that doesn’t seem to offer many hints as to why.
TLDR: Is there an easy tool or method to either confirm or rule out the out-of-memory condition is the cause of a segfault?
(top does not show an inordinate amount of memory use before crash)
On Linux, an out-of-memory condition can manifest in one of two ways:
brk()ormmap()call fails withENOMEM. Shortly thereafter, the application attempts to dereference the NULL pointer returned frommalloc()and crashes.As such, you can rule out OOMs by checking that strace doesn’t show
brk()ormmap()calls failing withENOMEM, and verifying that no OOM killer messages appear in dmesg.