Le 18.08.2012 11:56, Alex Bligh a écrit :
--On 18 August 2012 11:35:29 +0200 Denis BUCHER <dbucherml@xxxxxxxxxxxxx> wrote:OK, but my problem is that when I detect an "offending" process (using too much memory), it's already too late ! The strace will only show mmaps until "[crit] Memory allocation failed" ! Do you have a suggestion on how I could "intercept" these processes before the problem happens ?rlimit maybe. I'd suggest something is trying to allocate a 'negative' amount of memory. The real answer is to locate the bug. If you really want to do that, build/install debug versions of your s/w, attach gdb to the running process, and ask for a backtrace.
Mmmm I don't know how to to all that...
I just send you the end of strace, just by chance, maybe you can see something interesting ?
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b92e9929000
brk(0x2b91bbe72000) = 0x2b91bbe16000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b92e9a29000
brk(0x2b91bbe72000) = 0x2b91bbe16000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b92e9b29000
brk(0x2b91bbe72000) = 0x2b91bbe16000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b92e9c29000
brk(0x2b91bbe72000) = 0x2b91bbe16000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b92e9d29000
brk(0x2b91bbe72000) = 0x2b91bbe16000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b92e9f29000
munmap(0x2b92e9f29000, 34435072) = 0
munmap(0x2b92f0000000, 32673792) = 0
mprotect(0x2b92ec000000, 376832, PROT_READ|PROT_WRITE) = -1 ENOMEM (Cannot allocate memory)
munmap(0x2b92ec000000, 67108864) = 0
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b92e9e29000
munmap(0x2b92e9e29000, 35483648) = 0
munmap(0x2b92f0000000, 31625216) = 0
mprotect(0x2b92ec000000, 135168, PROT_READ|PROT_WRITE) = -1 ENOMEM (Cannot allocate memory)
munmap(0x2b92ec000000, 67108864) = 0
write(2, "[crit] Memory allocation failed,"..., 51) = 51
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(17282, 17282, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
chdir("/etc/httpd") = 0
rt_sigaction(SIGABRT, {SIG_DFL, [], SA_RESTORER|SA_INTERRUPT, 0x2b91b7f33be0}, {SIG_DFL, [], SA_RESTORER|SA_RESETHAND, 0x2b91b7f33be0}, 8) = 0
kill(17282, SIGABRT) = 0
rt_sigreturn(0x4382) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
Process 17282 detached