[Gc] OS X patch against 6.8: segfault fix

Allan Hsu allan at counterpop.net
Tue Oct 31 14:24:08 PST 2006


On Oct 26, 2006, at 5:52 PM, Boehm, Hans wrote:

> Thanks.  And sorry for the delay.
>
> Clearly the new code is better than the old.
>
> I assume that task_threads() implicitly allocates vm of exactly the
> required size?  This seems a bit brittle in that if you get the size
> wrong, it will fail very rarely.  Hence I wanted to double-check ...

The darwin/mach documentation I've seen on this is unclear.  
vm_allocate() only returns memory in page-sized chunks, and  
vm_deallocate frees the region that "...starts at the beginning of  
the virtual page containing address and ends at the end of the  
virtual page containing address + size - 1." My assumption is that  
task_threads allocates however many pages are needed to contain the  
resulting array and vm_deallocate will free the right number of pages  
when called.

> The code would look slightly clearer to me if the deallocation code at
> the end also used prev_list and prevcount, making it clear that it's
> just doing the same cleanup as in the loop.

I have no problem with this. I waffled between what you described and  
what I submitted in the patch.

	-Allan


More information about the Gc mailing list