Skip to content
Advertisement

Debugging a linux daemon process written in C

On occasion a daemon I wrote in C gets these error messages:

[Fri Dec 30 07:58:54 2016] listend[13944]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13948]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13949]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13950]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13951]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13952]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13953]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13954]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

[Fri Dec 30 07:58:54 2016] listend[13955]: segfault at 0 ip b7601e22 sp bf901d00 error 4 in libc-2.19.so[b7575000+1a7000]

My question is how can I examine that address in libc-2.19.so to see which function is being called when the error occurs? I tried using gdb

but I get :

$ gdb code/listen/i686-Linux/listend 
.
.
(gdb) info addr 0xb7575000
No symbol "0xb7575000" in current context.
(gdb) info addr 0xb771c000
No symbol "0xb771c000" in current context.

Advertisement

Answer

With the data you provide there’s very little that can be done here to make a diagnose on your problem. What I can infer is that the address, being 0, points to a NULL dereference in your code (you pass NULL as the pointer to a string address, or something similar, that makes your printf() call to fail — or similar, again) The address 0x1a7000 is where, in libc has been raised the exception. You probably can guess the function name, by executing nm(1) to your libc.so.xx.xx.xx. Dumping a core (by setting ulimit -c unlimited before executing your daemon) will allow to use the postmortem debugger. Or perhaps the source code of the daemon would help also. Sorry but your question is far from complete to be able to help. See How to create a Minimal, Complete, and Verifiable example for more information.

Advertisement