[Oberon] Project Oberon 2013 compiler does not like large heap objects (but does not complain either)
Michael Schierl
schierlm at gmx.de
Fri Dec 29 00:05:12 CET 2023
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
More information about the Oberon
mailing list