I've stopped the crashes that appear related to this on my box with the 
attached patch.  
config/gen/platform/darwin/memalign.c has a few unsigned variables that were 
being 
implicitly handled as (32-bit) ints, those variables are actually used as (or 
in the calculation of) 
memory addresses.  Needless to say, the lopped off bytes became an issue when 
parrot tried to 
deallocate memory in a chunk of address space that was never allocated in the 
first place.

The patch doesn't appear to have caused any issues with Intel 10.5 OS X builds 
(both 32 and 64 
bit), but it hasn't been heavily tested yet.
Index: config/gen/platform/darwin/memalign.c
===================================================================
--- config/gen/platform/darwin/memalign.c       (revision 30077)
+++ config/gen/platform/darwin/memalign.c       (working copy)
@@ -26,7 +26,7 @@
 
 /*
 
-=item C<static unsigned log2int(unsigned x)>
+=item C<static unsigned long log2int(unsigned long x)>
 
 RT#48260: Not yet documented!!!
 
@@ -34,13 +34,13 @@
 
 */
 
-static unsigned log2int(unsigned x) {
+static unsigned long log2int(unsigned long x) {
     return (x<2) ? 0 : log2int(x>>1)+1;
 }
 
 /*
 
-=item C<static unsigned roundDownPowerOf2(unsigned x)>
+=item C<static unsigned long roundDownPowerOf2(unsigned long x)>
 
 RT#48260: Not yet documented!!!
 
@@ -48,13 +48,13 @@
 
 */
 
-static unsigned roundDownPowerOf2(unsigned x) {
+static unsigned long roundDownPowerOf2(unsigned long x) {
     return (1 << log2int(x));
 }
 
 /*
 
-=item C<static unsigned roundUpPowerOf2(unsigned x)>
+=item C<static unsigned long roundUpPowerOf2(unsigned long x)>
 
 RT#48260: Not yet documented!!!
 
@@ -62,27 +62,27 @@
 
 */
 
-static unsigned roundUpPowerOf2(unsigned x)
+static unsigned long roundUpPowerOf2(unsigned long x)
 {
-    static unsigned one = 1;
-    unsigned log2Int = log2int(x);
+    static unsigned long one = 1;
+    unsigned long log2Int = log2int(x);
 
     return ((one << log2Int) == x) ? x : (one << (log2Int + 1));
 }
 
 /*
 
-=item C<static unsigned roundUpToPageBoundary(unsigned x)>
+=item C<static unsigned long roundUpToPageBoundary(unsigned long x)>
 
-RT#48260: Not yet documented!!!
+Returns the address of the page that contains the address x.
 
 =cut
 
 */
 
-static unsigned roundUpToPageBoundary(unsigned x)
+static unsigned long roundUpToPageBoundary(unsigned long x)
 {
-    unsigned roundedDown = trunc_page(x);
+    unsigned long roundedDown = trunc_page(x);
 
     return (roundedDown == x) ? x : (roundedDown + vm_page_size);
 }

Reply via email to