My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 226: Garbage Collector crashes on big endian platforms
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Feb 2013


 
Reported by bji-goo...@ischo.com, Feb 13, 2013
What steps will reproduce the problem?
1. Compile the attached Haxe program as C++ targeting a big endian platform (i.e. MIPS)
2. Run, it will crash after 13 iterations

What is the expected output? What do you see instead?

It shouldn't crash.


What version of the product are you using? On what operating system?

Haxe v2.10 (r5702), hxcpp 2.10 (r589), Linux on a MIPS architecture

Please provide any additional information below.

If I disable the GlobalAllocator::Collect() method (by making it immediately return true) the crash does not occur.


GarbageCollection.hx
711 bytes   View   Download
Feb 13, 2013
#1 bji-goo...@ischo.com
I have discovered that if I define USE_POSIX_MEMALIGN, the crash no longer occurs (without USE_POSIX_MEMALIGN it always occurs after the 13th iteration of the test).

However, it does subsequently hang in an infinite loop after iteration 60.

Feb 13, 2013
#2 bji-goo...@ischo.com
OK it appears that we've been able to fix this in our local copy of hxcpp.  Here is a diff showing the fix:

==== orig/GCInternal.cpp - fixed/GCInternal.cpp ====
486,488d485
<    #define CHECK_TABLE_LIVE \
<       if (*table && ((row[*table]) !=  gByteMarkID)) *table = 0;
< 
496c493
< 
---
>       
514c511
<                      if (row[pos+3] == gByteMarkID)
---
>                      if (row[pos+4+ENDIAN_MARK_ID_BYTE] == gByteMarkID)
517c514
<                         last_link = row+pos+2;
---
>                         last_link = row+pos+ENDIAN_OBJ_NEXT_BYTE;
523c520
<                          //GCLOG("Fill %d (%p+%d=%p) mark=%d/%d\n",size, row,pos, row+pos+4,row[pos+3], gByteMarkID);
---
>                          //GCLOG("Fill %d (%p+%d=%p) mark=%d/%d\n",size, row,pos, row+pos+4,row[pos+4+ENDIAN_MARK_ID_BYTE], gByteMarkID);
526,527c523,524
<                      if (row[pos+2] & IMMIX_ROW_HAS_OBJ_LINK)
<                         pos = row[pos+2] & IMMIX_ROW_LINK_MASK;
---
>                      if (row[pos+ENDIAN_OBJ_NEXT_BYTE] & IMMIX_ROW_HAS_OBJ_LINK)
>                         pos = row[pos+ENDIAN_OBJ_NEXT_BYTE] & IMMIX_ROW_LINK_MASK;
572c569
<       unsigned char time = mRow[0][inOffset+3];
---
>       unsigned char time = mRow[0][inOffset+4+ENDIAN_MARK_ID_BYTE];
645c642
<                if (row[pos+3] == gByteMarkID)
---
>                if (row[pos+4+ENDIAN_MARK_ID_BYTE] == gByteMarkID)
1367c1364
<                   if (row[pos+3] == gByteMarkID)
---
>                   if (row[pos+4+ENDIAN_MARK_ID_BYTE] == gByteMarkID)
2234c2231
<                unsigned char &mark = ((unsigned char *)(vptr))[-1];
---
>                unsigned char &mark = ((unsigned char *)(vptr))[ENDIAN_MARK_ID_BYTE];


Basically, the endian-specific values used to find the mark id were not being used everywhere they should.

I am not very familiar with this code though and am not certain that this fix is correct in all places, or that it doesn't miss something else.  My garbage collection test works now though with the above fixes.

Feb 13, 2013
Project Member #3 gameh...@gmail.com
Hi,
Your fixes look reasonable.  I started to do the endian fixes, but I did not have a proper test environment so gave up.  I'll put some changes into the svn version, then get you to check the result.
The other thing which might have problems with endian-ness is the RGB code in nme, but I guess the problems there should be pretty obvious. 
Status: Accepted
Feb 13, 2013
#4 bji-goo...@ischo.com
Thanks - the lines that I was most unsure about were the ones where ENDIAN_OBJECT_NEXT_BYTE are added.  I was not sure that those were correct, so if you could double-check those that would be great.  Thanks!

Feb 14, 2013
Project Member #5 gameh...@gmail.com
Hi
I have put your changes in - plus with a little bit of doco.  It is nice to add big-endian to the supported list.
Status: Fixed

Powered by Google Project Hosting