c - Who called atexit()? -


I have a program that unexpectedly leaves Linux and why I have a hard time finding out why No core dump, see). I kept an atexit (at the beginning of the program) and callback function is actually being called when the accident happens.

How can I know atexit callback function called? By reading the man page, the anneet is called on the deceptive (de ho!) Or is returned from the main; i can later exclude because at the end of main there is a bunch of printf and i do not see them. And I can already get out because there is no exit () in my program.

There is only one solution: It is the only possibility that the Library functions are being asked to exit? And where do I say? Is it possible to print a stack trace or is it possible to force the main dump from within the entity callback?

Calls like GDB to inspect the coredump in your art handler abort (), and GDB in Baktas command you Shows where it comes out, if the annex handler is run. Here's a demonstration:

  #include & lt; Stdlib.h & gt; Exit zero (zero) {Canceled (); } Zero Startup () {#ifdef Exit DO_EXIT (99); #endif} int main (int argc, char * argv []) {atexit (exit_handler); start up(); Return 0; }   

and is doing this:

  $ gcc -DDO_EXIT -g atexit.c $ ulimit -c unlimited $ / A.out aborted (core dump)) $ Gdb ./a.out core.28162 GNU GDB (GDB) Fedora 7.7.1-19.fc20 .. Core was generated by './a.out' program SIGABRT, Signaled with termination ended. # 0 __kernel_vsyscall 0xb77d7424 (in) different debuginfos missing, use: install debuginfo glibc-2.18-16.fc20.i686 (gdb) # 0 0xb77d7424 (in __kernel_vsyscall) # 1 (increase 0x42e1a8e7) bt from /lib/libc.so atexit.c from .6 # 2 0x42e1c123 (Close in between) 3 0x0804851b (in /lib/libc.so.6 # exit_handler): 6 # 4 0x42e1dd61 __run_exit_handlers () /lib/libc.so.6 # 5 0x42e1ddbd the exit of the /lib/libc.so.6 # of () in 6 0x0804852d atexit.c on startup (): 12 # 7 0x08048547 main (argc = 1, argv = 0xbfc39fb4) on atexit.c: 21   

As expected, it shows startup () exiting from calling.

You can also start this program in GDB, and interrupt debugging and set breakpoints in AXIT handler. >

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -