GCC 6.1.1 "Verilator internal fault" when trying to run on any file
I'm trying to integrate verilator's lint functionality into coala (coala-analyzer.org) so it can be used together with other static code analysis.
The issue is very simple to me but seems to occur only on my system, maybe related to the package I used.
Steps to reproduce¶
- Install the verilator package via the ArchLinux AUR package (https://aur.archlinux.org/packages/verilator/)
- Create a simple
flipflop.vfile with the example code given on https://en.wikipedia.org/wiki/Verilog#Example
verilator --lint-only flipflop.v
lasse@lssteady ~/tmp/vl % verilator --version Verilator 3.882 2016-03-01 rev verilator_3_882-1-gacff683
lasse@lssteady ~/tmp/vl % verilator --lint-only flipflop.v %Error: Verilator internal fault, sorry. Consider trying --debug --gdbbt %Error: Command Failed /usr/bin/verilator_bin --lint-only flipflop.v
Further Debug Data¶
I'm getting this also when running
verilator --cc or so. I tried other examples from the wiki article as well, same result. Marking this as high priority initially since it's not possible to use verilator with any basic example data, reprioritize as needed.
#6 Updated by Wilson Snyder about 2 years ago
You're using Antergos Linux, not Arch. Antergos is a rolling system, so I don't know how to create the same configuration you have. Also I downloaded Arch and it's a PITA to install, I see this page
and it's like 30 steps - isn't there something more sane to get a boot image? If you can provide a virtualbox .vdi file or .iso showing the issue I'll look at it, otherwise sorry but I can't really spend a few hours figuring all this out.
#7 Updated by Lasse Schuirmann about 2 years ago
Hey, you can download an ISO from http://antergos.org/ and install that really quick, there's a GUI for the installation so you don't have to go through the whole ArchLinux installation.
You can also use the Antergos Live ISO and try out my issue without installing the OS at all.
/me regretfully admits that he didn't have enough time in his GSoC to write express installation for ArchLinux for GNOME Boxes.
#9 Updated by Wilson Snyder about 2 years ago
- Status changed from New to AskedReporter
Well, got the OS up. Installed it, and your example runs fine. BTW I noted when installing it says:
l otrfan commented on 2016-03-26 I'm not actively using verilator anymore. I bumped the pkgver and it seemed to build (relatively) cleanly, but that's all the testing I did.
So basically you were already in a bad spot. If you want to debug further it's yours to maintain packaging for, or use a different distro which has an active maintainer. If you figure out that some code change is needed I'll of course take the patch back. Sorry.
#10 Updated by Jannis Harder about 2 years ago
I ran into the same issue when trying to use verilator on a recent arch system. It also happens when building from source, ignoring the unmaintained AUR package.
Since all versions of verilator that I tried seemed to be affected, I assumed some change in a dependency, or default compiler option caused this.
I finally figured out the cause when trying to compiler verilator with clang++ instead of g++. I got tons of the following warning:
./V3Ast__gen_impl.h:95:62: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
I read a short time ago that gcc now also optimizes away null checks on this pointers. As of gcc version "gcc (GCC) 6.1.1 20160501" it seems to be certainly the case. It doesn't seem that gcc is able to generate warnings for this though.
As a quick work-around I got verilator to work on the flipflop example by compiling with the gcc flag "-fno-delete-null-pointer-checks", which makes gcc assume that 0 is also a valid address and thus might negatively impact other optimizations too. A proper fix would be to change the code to be valid, well-defined C++ code. Due to the amount of warnings clang produced, and as I'm not familiar with the verilator code base, I didn't attempt to provide a fix for this.
#11 Updated by Wilson Snyder about 2 years ago
- Subject changed from "Verilator internal fault" when trying to run on any file to GCC 6.1.1 "Verilator internal fault" when trying to run on any file
- Category set to Configure/Make/Compiling
- Status changed from AskedReporter to Resolved
Excellent. It's strange that clang which gives that warning didn't use that optimization.
I added -fno-delete-null-pointer-checks to the configure script. If you could try the git version from scratch it would be appreciated.
The internals require this because a dynamic cast takes in NULL. It's a case where the standard is badly written, and to change would be a fairly major overhaul. The Verilator output code however was cleaned of this.
#12 Updated by Jannis Harder about 2 years ago
It seems the -fno-delete-null-pointer-checks flag is only added when specifying --enable-ccwarn during configure. As verilator produces warnings on my gcc version this does not compile.
Would you be open to patches that eliminate this undefined behavior from the verilator codebase and thus avoid the need to maintain work-around flags?
Also available in: Atom