NetBSD-Users archive

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

atexit handler access issue


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

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:

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

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

The flow is as given below

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

dlclose() --> 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,

Home | Main Index | Thread Index | Old Index