slate bootstrap bug status report

Timmy Douglas lists at timmy.tmbx.com
Mon May 14 09:19:59 PDT 2007


I've been looking into a bug in the bootstrap process.

After you make a new image with: Image bootstrapBasedOn: VM new, slate
tries to load that image, and that's where it fails.  The image file
is made by parsing a lot of slate files which are defined in
build.slate and then concatenating them into one function that
initializes a normal slate environment. Since some of the functions
used in earlier files depend on functions fully defined in later
files, pre-bootstrap.slate is loaded first with some common functions
defined in simpler terms to keep things from crashing because of
missing dependancies.

However, somewhere in numeric.slate, things go wrong.
The first define:

numerics define: #Comparable &parents: {Cloneable}.

causes the Cloneable object to be transformed into a Compareable
object, and things go spiraling out of control when Float is defined,
which somehow causes the #traits3 = #traitsWindow to invoke
CoercibleNumberMixin's specializer coerceTo (because Symbol's
inheritance graph has changed to have Float where Cloneable would be),
which fails on symbols because they don't have a level.

I added this code to vm.c to realized this, but I'm not sure if the
code is correct:

  #ifdef DEBUG_MSG
  fprintf(stderr, "%d ", i->framePointer);
  printSymbol(stderr, selector); fputc('\n', stderr); // this line existed already
#endif

#ifdef DEBUG_MSG


  unsigned long int ii=0;
  static char buffer[100];  
  
  
  for (ii = 0; ii < n; ii++) {
    unsigned long int offset, slotNum;
    unsigned long int _limit_;
    if (ObjectPointer_isSmallInt(args[ii])) {
      fprintf(stderr, "arg %d: %d\n", ii, ObjectPointer_asSmallInt(args[ii]));
      continue;
    }
    struct Object* mytraitsWindow = ObjectPointer_pointer(ObjectPointer_pointer(args[ii])->map->delegates->elements[0]);

    _limit_ = (PSObject_arraySize(ObjectPointer_pointer(args[ii])) - 1) + 1;
    unsigned long int numDelegates = PSObject_arraySize(mytraitsWindow->map->delegates);

    //fprintf(stderr, "delegate count: %d\n", numDelegates);

    for (offset = PSObject_firstSlotOffset(mytraitsWindow), slotNum=0;
         slotNum < PSObject_slotCount(mytraitsWindow);
         offset = offset + 4, slotNum++) {
      
      
      
      struct Object* traitsWindowSlotName = ObjectPointer_pointer(mytraitsWindow->map->slotTable->slots[slotNum].name);

        strncpy(buffer, PSObject_arrayElements(traitsWindowSlotName), PSObject_payloadSize(traitsWindowSlotName));
        buffer[PSObject_payloadSize(traitsWindowSlotName)] = 0;
        //fprintf(stderr, "slot arg[%d] slot[%d]: %s\n", ii, slotNum, buffer);



      if (strncmp(PSObject_arrayElements(traitsWindowSlotName),
                  "printName",
                  PSObject_payloadSize(traitsWindowSlotName)) == 0
          || 1) { /*i dunno..*/

        struct Object* oop = ObjectPointer_pointer(PSObject_slotValueAtOffset_(mytraitsWindow, offset));
        strncpy(buffer, PSObject_arrayElements(oop), PSObject_payloadSize(oop));
        buffer[PSObject_payloadSize(oop)] = 0;
        fprintf(stderr, "arg %d: %s\n", ii, buffer);
        if (strncmp(buffer, "Symbol", 7) == 0) {
          fprintf(stderr, "name: ");
          printSymbol(stderr, args[ii]);
          fprintf(stderr, "\n");
        }
        break;
      }
    }
  }

#endif



and some debugging output:


first, I put this kind of code all over numeric.slate:


#sym traitsWindow delegateNames do:
  [|:item|
     Console write: 20 to: 0 from: (#sym traitsWindow atSlotNamed: item) printName startingAt: 0].

Console write: 1 to: 0 from: '\n'startingAt: 0.


is executed at the top of numerics.slate and right before the definition of UniqueNumber where it crashes. The output is cleaned (strings weren't null terminated):

before:

Cloneable
Root traits
Derivable traits
Cloneable traits
Oddball
Oddball
Oddball
ByteArray traits
Oddball
ASCIIString traits
Symbol traits

after:

Float
Root traits
Derivable traits
Float traits
Oddball
Oddball
Oddball
ByteArray traits
Oddball
ASCIIString traits
Symbol traits


I'm guessing maybe something like derive is going bad?


debugging output with DEBUG_MSG defined:

216 atSlotNamed:
arg 0: Namespace
arg 1: Symbol
name: Cloneable
209 clone
arg 0: Comparable
209 restrictDelegation
arg 0: Comparable

you can see we try to do Cloneable clone, but calling Cloneable on the
namespace returs a Comparable--the object must have been modified?

Maybe if we try making it immutable we will get an error in define? I
haven't had much time recently to look further into it.




More information about the Slate mailing list