Date: Sun, 04 Feb 2001 19:10:37 -0500 From: Brian McGovern <mcgovern@spoon.beta.com> To: hackers@freebsd.org Subject: Re: exit() does not do dlclose()? Message-ID: <200102050010.f150Ab809972@spoon.beta.com> In-Reply-To: Your message of "Sun, 04 Feb 2001 15:12:25 PST." <200102042312.f14NCPk02811@vashon.polstra.com>
next in thread | previous in thread | raw e-mail | index | archive | help
I don't know how easy it would be to strip out the case I'm seeing. The program I'm working with is bascially a control application for vgetty's voice functions. It may be a case of stack smashing, as the call tends to be something like: main() -> function in loaded library -> exit(). However, I also saw it in the case when I'd basically have the function in the shared lib exit back to main(), and have the exit() function called from there. Let me see if I can create a 'simple' case that causes it. Otherwise, if you want a more complex example that requires a specific enviornment to demonstrate it, I'll send you my code-in-progress. -Brian > In article <200102041654.f14Gsh808001@spoon.beta.com>, > Brian McGovern <mcgovern@spoon.beta.com> wrote: > > I'm playing with an application that uses dlopen() to load some libraries. I > > use the _init function to set the libraries up. I've also set up the _fini > > functions to shut things down. > > > > I see, in the man page, that dlclose() will unload the libraries and call > > _fini. > > > > My question is whether or not exit() does the same thing? It currently doe s > > not appear to, although that would seem rather odd to me, given the other > > types of cleanup it does. > > It should clean them up including calling their _fini functions. From > src/libexec/rtld-elf/rtld.c: > > /* > * Cleanup procedure. It will be called (by the atexit mechanism) just > * before the process exits. > */ > static void > rtld_exit(void) > { > Obj_Entry *obj; > > dbg("rtld_exit()"); > wlock_acquire(); > /* Clear all the reference counts so the fini functions will be called. */ > for (obj = obj_list; obj != NULL; obj = obj->next) > obj->refcount = 0; > wlock_release(); > objlist_call_fini(&list_fini); > /* No need to remove the items from the list, since we are exiting. */ > } > > If you can come up with a reasonably self-contained test case that > shows a bug in this, I'll be happy to take a look at it. > > John > -- > John Polstra jdp@polstra.com > John D. Polstra & Co., Inc. Seattle, Washington USA > "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102050010.f150Ab809972>