[Oberon] Project Oberon 2013 compiler does not like large heap objects (but does not complain either)

Joerg joerg.straube at iaeth.ch
Fri Dec 29 01:34:22 CET 2023


I guess ORG.Store should generate an error if x.a > 07FFFFH

br
Jörg

> Am 29.12.2023 um 00:05 schrieb Michael Schierl <schierlm at gmx.de>:
> 
> Hello,
> 
> 
> Today I spent about half the day debugging an issue with large heap objects.
> 
> Consider this example:
> 
> MODULE X;
>  TYPE PD = POINTER TO D;
>    D = RECORD
>      large: ARRAY 512 * 1024 OF BYTE;
>      here: ARRAY 5 OF INTEGER;
>    END;
> 
>  VAR d: PD;
> 
>  PROCEDURE Go*;
>  BEGIN
>    NEW(d);
>    d.here[2] := 42;
>  END Go;
> 
> END X.
> 
> 
> In particular, the size of D is more than half a megabyte. (In practice
> it was a bunch of nested RECORDs so its size was not that obvious).
> 
> This results in the displacement to the LDR instruction becoming
> negative. If the system has more than 1 MiB of memory, it does not wrap
> back to the same location but instead corrupt some other memory 1MB
> before the location to be written.
> 
> Tested the official compiler and also Andreas' Extended Oberon compiler.
> 
> 
> Would have been nice to show a compile time error in such a situation so
> that the user knows they have to refactor and not silently corrupt some
> memory.
> 
> 
> Regards,
> 
> 
> Michael
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list