DevCPT bug

Post Reply
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

DevCPT bug

Post 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.
Attachments
Test.zip
(5.22 KiB) Downloaded 500 times
Romiras
Posts: 35
Joined: Tue Sep 17, 2013 5:55 am
Location: Tel-Aviv

Re: DevCPT bug

Post by Romiras »

Seems like new bug of Garbage Collector.
marco.ciot
Posts: 1
Joined: Mon Jun 23, 2014 2:15 pm

Re: DevCPT bug

Post 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 532 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);
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: DevCPT bug

Post 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?
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: DevCPT bug

Post by Ivan Denisov »

Marco, I tested you solution. All works fine. The numbers logged from 999 to 0.
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: DevCPT bug

Post 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
Post Reply