[Oberon] PO: Illegal memory access in GC

Hellwig Geisse hellwig.geisse at mni.thm.de
Fri May 15 10:42:52 CEST 2020

Hi all,

I'm running Project Oberon (current version) on my
own simulator for the RISC-5 processor. Yesterday
I wanted to try Andreas Pirklbauer's Extended Oberon
(btw, excellent explanations - thanks for that),
but I ran into the very same error as I did when
bringing up the original Project Oberon:
"Reading from unknown I/O device 15", which was
triggered by a read access to location -4.
My simulator does monitor all memory accesses for
correctness (out-of-bounds, alignment), which I
suspect Peter De Wachter's simulator does not.
Otherwise, this error should have shown up at
many other sites too.

The reason for the illegal memory read lies within
the garbage collector in module Kernel.Mod:

WHILE pvadr # 0 DO
  SYSTEM.GET(pvadr, p); SYSTEM.GET(p-4, offadr);
  IF (p >= heapOrg) & (offadr = 0) THEN ...

If after the first GET the pointer p is 0 (NIL),
the second GET at p-4 becomes an access to memory
location -4. This GET should be guarded by the
test "IF (p >= heapOrg) ...", either directly in
place, or (better) by separating the compound test
in the following IF statement.

There is a similar sequence with a dangerous GET
a few lines further down:

IF offset # -1 THEN (*down*)
  SYSTEM.GET(pos+offset, r); SYSTEM.GET(r-4, offadr);
  IF (r >= heapOrg) & (offadr = 0) THEN ...

As soon as I inserted the tests, the illegal access
was gone and Extended Oberon was running.

Best regards,

More information about the Oberon mailing list