[Oberon] Stack overflow in ORB.OutType

Michael Schierl schierlm at gmx.de
Mon Jun 15 21:44:10 CEST 2020


Hello,


Today I remembered that a few weeks ago I stumbled upon a stack overflow
in the RISC5 Oberon compiler :-(


When compiling this minimal example:

MODULE A;
  TYPE X* = POINTER TO XD;
    XD = RECORD
      a*: POINTER TO XD;
    END;
END A.

MODULE B;
  IMPORT A;
  PROCEDURE P*(a: A.X);
  END P;
END B.


During writing of the symbol file of module B, a stack overflow happens
in ORB.OutType (Both the vanilla version and Andreas' Extended Oberon
version).

It does not occur if you change either one of the following:
- Make type XD exported (XD*)
- Make field XD.a unexported
- Change field XD.a to be of type X (use the named pointer type)
- Make PROCEDURE P unexported

Probably this situation is pathological, and usually you probably don't
want this code style, and it is easy to work around (easiest case: Just
use named pointer types).

I still would like to understand what causes the error.

I know that cyclic types can cause infinite recursion and therefore
stack overflows when you do not take precautions to break the cycles,
but I do not fully understand how the code is supposed to break them and
why no cycles should remain afterwards. So I cannot tell where the
design is violated and needs fixing...


Any ideas?


Regards,


Michael


More information about the Oberon mailing list