[Gc] Pushing Registers for Collector Thread
Jonathan Chambers <[email protected]> Fri, 5 Sep 2014 09:14:11 -0400
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <CA+rpb=CUuq0gCdUQuxo3Vy3tHN4kyFd0s05W2H4Z=zNUxxU=JQ@mail.gmail.com> |
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 _______________________________________________ bdwgc mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/bdwgc