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

Cygwin verilator_coverage fails due to cygwin bug in getline() #1349

Closed
veripoolbot opened this issue Sep 19, 2018 · 10 comments
Closed

Cygwin verilator_coverage fails due to cygwin bug in getline() #1349

veripoolbot opened this issue Sep 19, 2018 · 10 comments
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Lloyd Gomez
Original Redmine Issue: 1349 from https://www.veripool.org


Hello,

I am trying to install Verilator 4.002 on Cygwin. Compilation looks ok but I get a failure when running the "make test" step:

-- COVERAGE ----------------
/cygdrive/c/cygwin64/home/lloyd/Downloads/verilator-4.002/bin/verilator_coverage --annotate logs/annotated logs/coverage.dat
%Error: Verilator_coverage aborted.
%Error: Command Failed /cygdrive/c/cygwin64/home/lloyd/Downloads/verilator-4.002/bin/verilator_coverage_bin_dbg --annotate logs/annotated logs/coverage.dat
make[1]: *** [Makefile:73: run] Error 255
make[1]: Leaving directory '/cygdrive/c/cygwin64/home/lloyd/Downloads/verilator-4.002/examples/tracing_c'
make: *** [Makefile:221: examples] Error 10

I'm not sure how to debug this and figure out what the problem is. These are the steps I did to do the installation:

% export SYSTEMC_INCLUDE="/usr/local/systemc-2.3.2/include"
% export SYSTEMC_LIBDIR="/usr/local/systemc-2.3.2/lib-cygwin64"
% export LD_LIBRARY_PATH="/usr/local/systemc-2.3.2/lib-cygwin64:$LD_LIBRARY_PATH"
% mkdir /usr/local/verilator-4.002
% cd ~/Downloads
% tar -xvzf verilator-4.002.tgz
% cd verilator-4.002
% unset VERILATOR_ROOT
% ./configure --prefix=/usr/local/verilator-4.002
% make
% make test

My Cygwin version is as follows and I am running on Windows 10:

lloyd@Lloyd-X1 ~/Downloads/verilator-4.002
$ uname -sra
CYGWIN_NT-10.0 Lloyd-X1 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin

Any help would be appreciated.

Regards,
Lloyd

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-09-19T08:49:06Z


If you run the verilator_coverage_dbg executable under gdb then do "bt" get a backtrace, what do you get?

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Aria Kraft
Original Date: 2018-09-19T19:26:43Z


This looks to be caused by two getline calls in VlcTop.cpp expecting \r\n in Cygwin I believe. A quick fix can be made by using something like safeGetline, example: http://stackoverflow.com/a/6089413
although the way logs/coverage.dat is created or processed could resolve the issue as well.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Lloyd Gomez
Original Date: 2018-09-20T05:54:06Z


Here's the output from gdb (I apologize, I'm not an expert on Cygwin and gdb in general...):

lloyd@Lloyd-X1 ~/Downloads/verilator-4.002/examples/tracing_c
$ gdb ../../bin/verilator_coverage_bin_dbg.exe 
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../../bin/verilator_coverage_bin_dbg.exe...done.
(gdb) r  --annotate logs/annotated logs/coverage.dat
Starting program: /cygdrive/c/cygwin64/home/lloyd/Downloads/verilator-4.002/bin/verilator_coverage_bin_dbg.exe --annotate logs/annotated logs/coverage.dat
[New Thread 7832.0x45dc]
[New Thread 7832.0xd80]
[New Thread 7832.0x31ac]
[New Thread 7832.0x30f4]
[New Thread 7832.0x1768]

Program received signal SIGABRT, Aborted.
0x00000003f29cca0b in cygstdc++-6!_ZNSs7reserveEm () from /usr/bin/cygstdc++-6.dll
(gdb) bt
#0  0x00000003f29cca0b in cygstdc++-6!_ZNSs7reserveEm () from /usr/bin/cygstdc++-6.dll
#1  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-09-20T06:05:57Z


Try recompiling with -O0 or updating your GCC package, this seems a GCC/Cygwin bug.

https://www.mail-archive.com/cygwin@cygwin.com/msg153502.html

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Lloyd Gomez
Original Date: 2018-09-20T06:44:57Z


Thanks, Wilson. 4.002 is working fine on my CentOS 7.3 running inside Oracle VM VirtualBox so I'll just verilate there for now and worry about Cygwin later. You can close this issue.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-09-23T19:44:53Z


Glad it is working now.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Affe Mao
Original Date: 2018-11-24T08:36:55Z


Hi,

I had exactly this same situation. After some tracing works, I come to this quick and dirty fix:

$ diff src/VlcTop.cpp ../VlcTop.cpp
43c43
<
---
>       char linebuf[1000];
45,46c45,46
<       string line;
<       getline(is, line);
---
>       is.getline(&linebuf[0],1000,'\n');
>       string line(linebuf);
220a221,222
>       char linebuf[1000];
>
223,224c225,226
<           string line;
<           getline(is, line);
---
>           is.getline(&linebuf[0],1000,'\n');
>               string line(linebuf);

src/VlcTop.cpp is the original file,
../VlcTop.cpp is my fix.

It looks like

getline(is, line);
</code>

doesn't work, but

is.getline(&linebuf[0],1000,'\n');
</code>

works.

Is that because Cygwin's Stdc++ library requires an more strict initialization of

string line;
</code>

?

Cheers~

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-11-25T23:47:47Z


Thanks for figuring out a work around, will need to decide how to best support this. Note the code as written is legal, please also report this problem to the cygwin maintainers.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-11-27T00:13:04Z


Thanks for the patch.

Work around added to git towards 4.008.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-12-01T20:17:47Z


In 4.008.

@veripoolbot veripoolbot added area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

1 participant