Skip to content

Corruption issue in 3.3.1

Hi, I have an issue and I've hit a wall. I've finally come to the conclusion that the issue appears in 3.3.1 but not in 3.2.2. Whereas I would like to produce a small snippet to demonstrate the issue, it appears to be "so" random I've not managed it.

I have a tight loop with a goto and a lookup table sized case statement and I'm using a global variable called 'stack' which is a Class instance created once during initialisation. I can iterate the loop a number of times, then for no apparent reason, the value of 'stack' changes despite no code changes other than local integer assignments. If I add a "WriteLn" just before the apparent corruption, the corruption goes away then appears later somewhere else. If I compile in 3.2.2, it works perfectly.

If anyone has any ideas how I can go about narrowing this down (given the feast appears to move every time I make a change), please could you point me in the right direction.

The code looks something like this;

MainLoop:
  WriteLn(Format('MainLoop, stack=%p',[Pointer(stack)]));

  if debug then DebugLine;
  case TCmdType(pc^) of
    .. cases ...
    for_:
      begin
        Inc (pc);
        index := TPInt16(pc)^;
        // << CORRUPTION APPEARS IN HERE SOMEWHERE
        // uncommenting the WriteLn fixes "this" local issue
        //WriteLn(Format('!!!!!!!!! %p',[Pointer(stack)])); 
       end;
    ... cases
   end
   Inc (pc);
   goto MainLoop

Note; this is 3.3.1 compiled from source as per the docs in Linux (Debian Trixie) on a 64-bit PC.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information