Re: [Gc] Pushing Registers for Collector Thread
Bruce Hoult <[email protected]> Mon, 8 Sep 2014 00:01:40 +1200
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <CAMU+EkxFq1huh87WTX6K8++Oj8fSNC4sDFOVXPXVrTLZbVThyA@mail.gmail.com> |
Hi Jonathan, First, note that GC_push_stack_for() exists only in win32. Other OSes are organised a little differently. But in general, the registers for the current thread are not supposed to be pushed by GC_push_all_stacks because that has already been done elsewhere. Look at GC_push_roots in mark_rts.c. The last thing is calling GC_push_other_roots() if it is set. On posix and win32 there is a default function that does the pushing of stacks and thread registers. But immediately before that, GC_push_roots() calls GC_push_regs_and_stack(), which is what is supposed to push the registers for the current thread. It uses GC_with_callee_saves_pushed() in machdep.c, which on win32 does a setjmp, which saves the registers in a local structure in that function. Perhaps this is not working for you, or you have the wrong #DEFINEs to make it work? On Sat, Sep 6, 2014 at 1:14 AM, Jonathan Chambers <[email protected]> wrote: > Hello, > > Posting to the mailing list an issue one of our customers raised with us > and on github. We (Unity) use bdwgc within the Mono VM. We are running an > older version, but the issue highlighted still seems to persist in master. > > https://github.com/ivmai/bdwgc/issues/50 > > I believe this may apply to more architectures/platforms, but at the > moment I'll reference Win64. In GC_push_stack_for, all threads push their > stack sections. However, when pushing register values the current thread is > skipped: > > https://github.com/ivmai/bdwgc/blob/master/win32_threads.c#L1365 > > This leads to a case where memory may be collected while still in use. > Suppose an function allocates memory from the GC and it gets stored in a > volatile register (RCX for example on Win64). No pointer on the stack or > managed heap reference this allocation. Now a collection is triggered. > > If any subsequent functions in the call chain between the allocating > function and GC_push_stack_for does use RCX, the original value should be > pushed onto the stack and restored later as it's a volatile register. This > stack reference will be found and marked since we push the current thread > stack. > > However, if any subsequent functions in the call chain between the > allocating function and GC_push_stack_for does *not* use RCX the reference > will be not be marked and will be collected. > > On Windows/OSX this seems to always be the case. In pthread_stop_world.c I > see calls to GC_save_regs_in_stack for SPARC and Itanium. Is there a reason > this is not done/needed for all platforms? > > If this is indeed a bug, we can provide patches for all the platforms we > support. > > Thanks, > Jonathan > > -- > This message has been scanned for viruses and > dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is > believed to be clean. > _______________________________________________ > bdwgc mailing list > [email protected] > https://lists.opendylan.org/mailman/listinfo/bdwgc > _______________________________________________ bdwgc mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/bdwgc