Page 1 of 1
issue-#191 Compiler trap by erroneous program
Posted: Thu Nov 08, 2018 3:18 pm
by Zinn
The compiler produce a NIL dereference (read) trap instead of an error message
Code: Select all
MODULE TestCompilerError;
CONST
length = 5;
PROCEDURE Name* (): POINTER TO ARRAY OF CHAR;
VAR string: POINTER TO ARRAY OF CHAR;
BEGIN
NEW(string, LEN length + 1);
RETURN string
END Name;
END TestCompilerError.
Reported by Rainer Neubauer.
Re: Compiler trap by erroneous program
Posted: Fri Nov 09, 2018 7:37 am
by Josef Templ
I can confirm the bug and I have added an issue for this.
see
https://redmine.blackboxframework.org/issues/191.
Helmut, can you rename this topic to the usual form with the issue-#191 prepended?
- Josef
Re: issue-#191 Compiler trap by erroneous program
Posted: Sat Nov 10, 2018 2:19 am
by luowy
The easiest way is guard the "node" not NIL, I didn't find out what side effects it has.
DevCPB.StParN
Code: Select all
....
ELSIF f IN intSet THEN
IF f = Int64 THEN Convert(x, DevCPT.int32typ) END;
IF (x.class = Nconst) & (x.conval.intval <= 0) THEN err(63) END;
node := p.right;
IF node # NIL THEN (*+++*)
WHILE node.link # NIL DO node := node.link END;
node.link := x; p.typ := p.typ.BaseTyp
END (* +++ *)
ELSE err(111)
END
....
luowy
Re: issue-#191 Compiler trap by erroneous program
Posted: Sat Nov 10, 2018 11:48 am
by Josef Templ
thanks, luowy, I will look into this tomorrow.
- Josef
Re: issue-#191 Compiler trap by erroneous program
Posted: Sun Nov 11, 2018 11:56 am
by Josef Templ
I have fixed the trap as proposed by luowy.
In addition, I have added trivial error recovery code:
instead of appending to a non-empty list in the error case, the first element is inserted into the list.
The error message has been generated before.
For the changes see
https://redmine.blackboxframework.org/p ... 4e641e5c4b
- Josef
Re: issue-#191 Compiler trap by erroneous program
Posted: Mon Nov 12, 2018 2:36 pm
by luowy
the revised code works well, but the title is a bit fuzzy, how about "compiler trap by NEW procedure" ?
Re: issue-#191 Compiler trap by erroneous program
Posted: Mon Nov 12, 2018 9:10 pm
by Josef Templ
luowy wrote:the revised code works well, but the title is a bit fuzzy, how about "compiler trap by NEW procedure" ?
I agree that the title could be improved.
However, it should also not remove the fact that the trap is only a follow-up error after another error.
This is hard to express in only a few words.
The precise title would be something like this:
"Compiler trap after invalid first dimension of dynamic array NEW"
- Josef
Re: issue-#191 Compiler trap by erroneous program
Posted: Tue Nov 20, 2018 8:04 pm
by Josef Templ
any suggestions about the title?
Otherwise this topic is also ready for voting.
- Josef