-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash on package definition in interface decl. #1083
Conversation
223658d
to
14e19ec
Compare
I think the relevant bit is in 6.5.6.1:
...
else if (class != C_SIGNAL)
sem_error(t, "invalid object class %s for port %s",
class_str(class), istr(tree_ident(t))); |
src/parse.c
Outdated
if (tree_has_type(p0)) | ||
type_add_param(type, tree_type(p0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (tree_has_type(p0)) | |
type_add_param(type, tree_type(p0)); | |
if (class_has_type(tree_class(p0))) | |
type_add_param(type, tree_type(p0)); | |
else | |
type_add_param(type, type_new(T_NONE)); // Will raise error later |
src/parse.c
Outdated
if (tree_has_value(p0)) | ||
tree_set_flag(decl, TREE_F_CALL_NO_ARGS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can merge this into the loop below to avoid duplicating the check above. E.g.
if (i == 0 && tree_has_value(p))
tree_set_flag(decl, TREE_F_CALL_NO_ARGS);
14e19ec
to
f0b946c
Compare
Thanks for the review. Implemented the suggested change and merged the special case for the first port into the loop. |
My own instance of a fuzzer (libFuzzer based, nvc-fuzz) found a crash.
If instead of the usual
package <x> is new ...
in an interface a full package definitionpackage <x> is ... end package;
was given, then parsing did crash.With the added simple checks, the crash no longer happens and the parser gives the reasonable error of
unexpected end while parsing interface package declaration, expecting new
.Note: The standard is a bit moot in the definition, but I think to understand it so that generic package in interfaces may only be defined in generic interfaces.
But NVC allows them everywhere. E.g. the following is analyzing, elaborating and running without error:
Cheers