Page 1 of 1

DevCPT bug

Posted: Tue Jun 24, 2014 3:33 am
by Ivan Denisov
Marco Ciot wrote:The affected module is DevCPT.

The bug is very old. I guess it was there in the original Oberon Compiler written by N. Wirth, already. (And never discovered so far?!?) If this particular language construct is used, however, it leads to Heap Corruption.

Re: DevCPT bug

Posted: Tue Jun 24, 2014 8:17 am
by Romiras
Seems like new bug of Garbage Collector.

Re: DevCPT bug

Posted: Tue Jun 24, 2014 10:17 am
by marco.ciot
No, it's definetely a compiler bug.
I have fixed it in my branch of BlackBox.

I added a Debug Statement in DevCPT, that shows what's done wrong at compile time:
DevCPT.zip
DevCPT with debug statement for hidden pointers.
(18.69 KiB) Downloaded 545 times
Fixed excerpt from DevCPT:

Code: Select all

	PROCEDURE OutRecurseBaseTypeForHdFlds (typ: Struct; adr: INTEGER);
	BEGIN
		IF typ.BaseTyp # NIL THEN OutRecurseBaseTypeForHdFlds(typ.BaseTyp, adr); END;
		OutFlds(typ.link, adr, FALSE);
	END OutRecurseBaseTypeForHdFlds;

	PROCEDURE OutHdFld(typ: Struct; fld: Object; adr: INTEGER);
		VAR i, j, n: INTEGER; btyp: Struct; debugNow: BOOLEAN;
	BEGIN
		IF typ.comp = Record THEN
			IF typ.BaseTyp # NIL THEN OutRecurseBaseTypeForHdFlds(typ.BaseTyp, adr); END;
			OutFlds(typ.link, adr, FALSE);
Additionally the finger printing needs to be fixed, as well:

Code: Select all

	PROCEDURE FPrintStr*(typ: Struct);
		VAR f, c: SHORTINT; btyp: Struct; strobj, bstrobj: Object; pbfp, pvfp: INTEGER;

		PROCEDURE ^FPrintFlds(fld: Object; adr: INTEGER; visible: BOOLEAN);

		PROCEDURE FPrintRecurseBaseTypeForHdFlds (typ: Struct; adr: INTEGER);
		BEGIN
			IF typ.BaseTyp # NIL THEN FPrintRecurseBaseTypeForHdFlds(typ.BaseTyp, adr); END;
			FPrintFlds(typ.link, adr, FALSE);
		END FPrintRecurseBaseTypeForHdFlds;

		PROCEDURE FPrintHdFld(typ: Struct; fld: Object; adr: INTEGER);	(* modifies pvfp only *)
			VAR i, j, n: INTEGER; btyp: Struct;
		BEGIN
			IF typ.comp = Record THEN
				IF typ.BaseTyp # NIL THEN FPrintRecurseBaseTypeForHdFlds(typ.BaseTyp, adr); END;
				FPrintFlds(typ.link, adr, FALSE);

Re: DevCPT bug

Posted: Sun Jun 29, 2014 4:52 pm
by Ivan Denisov
Marco, thank you for detecting this bug and for suggested solution!
marco.ciot wrote:I have fixed it in my branch of BlackBox.
Is your branch available somewhere?

Re: DevCPT bug

Posted: Mon Jun 30, 2014 10:28 am
by Ivan Denisov
Marco, I tested you solution. All works fine. The numbers logged from 999 to 0.

Re: DevCPT bug

Posted: Mon Dec 15, 2014 9:50 pm
by Ivan Denisov
This bugfix was included to alpha1 Center version of BlackBox.

The last development version is available from:
http://blackboxframework.org/unstable/master