Skip to content
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

SegFault in genrtlil #810

Closed
ZipCPU opened this issue Feb 13, 2019 · 2 comments
Closed

SegFault in genrtlil #810

ZipCPU opened this issue Feb 13, 2019 · 2 comments

Comments

@ZipCPU
Copy link
Contributor

ZipCPU commented Feb 13, 2019

I traced a segfault down to the current_ast->dumpAst(*) line below at line 1568 in genrtlil.cc. As far as I can tell, this was created from calling $past() on an object of zero width. (Yes, this is a bug, but Yosys shouldn't segfault on this bug. Fixing the width in the source file eliminated the segfault too.)

// everything should have been handled above -> print error if not.
default:
	for (auto f : log_files)
		current_ast->dumpAst(f, "verilog-ast> ");
	type_name = type2str(type);
	log_file_error(filename, linenum, "Don't know how to generate RTLIL code for %s node!\n", type_name.c_str());

Expected behavior

An error message indicating the line of code with a problem. (The simple test cases I've created to try to replicate this behavior have failed to do so.)

It seems as though under certain conditions (I'm not quite sure which), current_ast is never getting set. A further look into the source, suggests this call should be with respect to this and not current_ast--at least in those cases where current_ast is NULL. Changing current_ast to "this" fixed the problem and produced a valuable error message.

@ZipCPU
Copy link
Contributor Author

ZipCPU commented Feb 13, 2019

Here's the design that caused the bug.

master_axi.zip

The obvious bug is that the widths of several items are zero. The segfault was the unexpected part.

@ZipCPU
Copy link
Contributor Author

ZipCPU commented Feb 22, 2019

The proposed fix handles this bug. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant