Skip to content
Advertisement

Application is getting killed without any reason. Suspecting high BSS. How to debug it?

I have been running my application successfully in CentOs6.6. Recently, the hardware(motherboard and RAM) was updated and my application is getting killed now without any reason at all.

JavaScript

File and ldd output

JavaScript

Output of strace

JavaScript

GDB

JavaScript

While debugging, observed that the bss memory is huge(~6GB). The system has 4GB RAM and I think this could be the reason for the issue.

JavaScript

The application contains many .h files and many datastructures and so it is difficult for me to identify why BSS is been raised to 6GB.

Could anyone please suggest how to identify which file is causing this? or any other easier way to debug this?

Advertisement

Answer

It seems that problem really is huge BSS size. I have asked you to show output of LD_DEBUG=all /lib64/ld-linux-x86-64.so.2 /path/to/exe in comments.

/lib64/ld-linux-x86-64.so.2 is runtime linker which is used by OS to load your binary in process memory during execve system call. Runtime linker is responsible for parsing executable format, loading all sections and dependencies in memory, performing all required relocations and so on. Setting environment variable LD_DEBUG to all we instruct runtime linker to generate debug output.

[root@localhost PktBlaster]# LD_DEBUG=all /lib64/ld-linux-x86-64.so.2 /root/Veryx/PktBlaster/PktBlaster 851: file=/root/Veryx/PktBlaster/PktBlaster [0]; generating link map /root/Veryx/PktBlaster/PktBlaster: error while loading shared libraries: /root/Veryx/PktBlaster/PktBlaster: cannot map zero-fill pages: Cannot allocate memory

Searching for this error message in source code of runtime linker(glibc-2.17 elf/dl-load.c, lines ~1400) we see:

JavaScript

dl-loader is in process of loading BSS segment, which by optimizations is stored in binary format as just number of bytes, that must be initialized to zero. Loader tries to allocate through mmap zero initialized memory block(MAP_ANONYMOUS) and get error from the OS:

JavaScript

From man 2 mmap:

ENOMEM No memory is available, or the process’s maximum number of mappings would have been exceeded.

So it seems that for whatever reason OS cannot fulfill loader request for memory. Either some limits are used(systemd, process limit, some security LKM, whatever) or simply there are not enough free memory in kernel.

To determine what object file generates most part of the BSS – use

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement