Skip to content
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

gef invoked oom-killer for core file from a mem-leak process #1012

Closed
jqguo367 opened this issue Oct 17, 2023 · 7 comments
Closed

gef invoked oom-killer for core file from a mem-leak process #1012

jqguo367 opened this issue Oct 17, 2023 · 7 comments
Labels

Comments

@jqguo367
Copy link

I have a core file which is from a 32-bit process which has memory leak issue. The core file is 3G+ in size.
I'd like to dump the heap chunks to infer which memory allocations were leaked.

But gdb 8.1 (+ gef) would be oom-killed after a couple of minues after I issue command "heap chunks".

From the /var/log/messages:
Oct 17 17:16:29 USSP04-0-0-1 kernel: [13741673.479615] Out of memory: Kill process 15272 (gdb-8.1) score 789 or sacrifice child
Oct 17 17:16:29 USSP04-0-0-1 kernel: [13741673.481768] Killed process 15272 (gdb-8.1), UID 0, total-vm:16854184kB, anon-rss:15290676kB, file-rss:1496kB, shmem-rss:0kB

Is there GEF configuration settings which can avoid OOM ?

@hugsy
Copy link
Owner

hugsy commented Oct 17, 2023

Is there GEF configuration settings which can avoid OOM ?

It's impossible for us to know what causes your issue, because it's too vague. So we cannot answer your question.

If you want us to consider examining this situation, file another issue and properly fill the template with a reproduction case.

@jqguo367
Copy link
Author

jqguo367 commented Oct 18, 2023

The reason why gdb+gef was oom-killed is because "heap chunks" command was using a lot of memory. The command seems output the result only after the scaning of the whole heap completed. To reduce memory consupmtion, It shoud output what already got while it perform scanning.

You can easily reproduce the issue with the following program.

`
#include <stdlib.h>
#include <stdio.h>

int main() {

for (int i = 0; i< 10000000; i++) {
char *p = (char* )malloc(1);
p[0] = 0x1;
}
abort();
return 0;
}
`

With the core file generated, then analyse it using "heap chunks" command. Of course, whether OOM killer can be triggered or not immediately depends on the RAM avaiable on the machine.

@jqguo367
Copy link
Author

With a coredump from a memory leak process, there are vast number of heap chunks inside the process space. So GEF OOM issue can occur.

@jqguo367
Copy link
Author

Can this be improved ?

@hugsy
Copy link
Owner

hugsy commented Oct 26, 2023

Can this be improved ?

GEF wasn't build for strong support for coredumps because it massively relies on information from the procfs. So it probably can be improved, but no timeline. Feel free to send us a PR.

Copy link

stale bot commented Dec 26, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue.

@stale stale bot added the stale label Dec 26, 2023
Copy link

stale bot commented Jan 31, 2024

This issue has been automatically closed because it has not had recent activity. If you are the owner of this issue, you can either re-open it and provide a more complete description; or create a new issue. Thank you for your contributions.

@stale stale bot closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants