NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

atexit handler access issue



Hi,

I am using NetBSD libraries and facing some issue with respect to
'atexit_handler_stack'

I have written one function atexit_remove() which is called from
__dlclose() of rtld, to unregister the
exit handlers in the user defined library i.e to resolve the Issue
posted in the mail link below:

http://mail-index.netbsd.org/netbsd-users/2009/07/08/msg004027.html

For this i added the atexit_remove function in the file
'src/lib/libc/atexit.c' which will be called
from the file src/libexec/ld.elf_so/rtld.c' during the dlclose of the library.

$ cat src/libexec/ld.elf_so/rtld.c

:
atexit_remove (obj->mapbase, obj->textsize)
:

Basically this function takes the text segment of the library being
unmapped in dlclose and
scans for any exit handlers present.

This is done by looking into the exit handler stack
'atexit_handler_stack' in the file 'src/lib/libc/atexit.c'

In the atexit_remove function is written in libc in the file
'src/lib/libc/atexit.c'

When i access the stack pointer 'atexit_handler_stack' as given in
atexit_remove() the
stack is always NULL.

$cat src/lib/libc/atexit.c
:

 struct atexit_handler *prevp;
 prevp = atexit_handler_stack;
 if ((prevp) == NULL)                 <---------------- Here its NULL
       write(1,"NULL\n",6);
:

The flow is as given below

RTLD : rtld.c file
                                             LIBC : atexit.c file

dlclose() --> atexit_remove(obj->mapbase,obj->textsize)
                                    |
                                    |
---------------------------------------------------->
atexit_remove(obj->mapbase,obj->textsize)

                                             |

                                             |-----> access
'atexit_handler_stack' to scan the exit handlers

                                                             (This is
always NULL)
I am not able to understand why 'atexit_handler_stack' is coming as NULL.

And in my test code i have registered exit handlers using atexit().

Could anyone help me in this regard?

Thanks & Regards,
Channa


Home | Main Index | Thread Index | Old Index