Re: Traversing the stack frame and identifying "references"
Hans Boehm <[email protected]> Sun, 28 Jan 2007 11:17:24 -0800 (PST)
| Newsgroups | gmane.comp.programming.garbage-collection.general |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 15 Jan 2007, David Chase wrote: > [Unmesh Joshi:] > >> But how can it be done when the garbage collector is written for > >> languages like C++. Do we need to somehow ask the compiler to do > >> that? Or some other techniques are used? > > And I realized I did not really answer your question. > If you stick with the stock threading systems, you > may need to reverse-engineer it. POSIX, at least at > one time, had some facility to enumerate threads, but > no guarantee that the threads that you got were all > of them, or were still active when you received word > of their existence. (It's been something like twenty > years, perhaps they have fixed this.) > On Posix systems, we actually insist on being able to intercept thread creation, so that we can keep track of live threads. There are different ways to do that, all imperfect: - Insist that clients include a header file. - Intercept symbols at the linker level. (On ELF systems, the dynamic library name resolution rules make this fairly easy with dynamic libraries, except for more recently introduced issues with symbol versioning.) On Windows systems, it is sort of possible to be notified automatically on thread creation, except that you run into some nasty locking/deadlock issues. Hans