Skip to content

Heuristic to increase chances of resolvng the stack #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion elfcore/src/coredump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,21 @@ fn get_va_regions(pid: Pid) -> Result<(Vec<VaRegion>, Vec<MappedFile>, u64), Cor
});
}

maps.sort_by_key(|x| x.begin);
// When the system is under stress and might OOM, or the program
// whose core dump is being captured might be terminated by some
// watchdog, it should be preferred to save the smaller regions of the
// VA space first as these are more likely to have the stack memory
// as opposed to the heap.
//
// As for the OOM argument, if the memory being read was paged
// out, reading it brings it back from the swap file increasing the memory
// pressure and increasing the chances of OOM-ing the system as
// Linux overcommits by default. That said, saving the smaller VA
// regions first likely helps to captre more and likely the stack memory.
//
// Sort the VA regioon by the size increasing to have better chances of
// capturing the stack memory before the program goes away.
maps.sort_by_key(|x| x.end - x.begin);

Ok((maps, mapped_files, vdso))
}
Expand Down