Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

Issue #1349

Cygwin verilator_coverage fails due to cygwin bug in getline()

Added by Lloyd Gomez 3 months ago. Updated 16 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Configure/Make/Compiling
% Done:

0%


Description

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

History

#1 Updated by Wilson Snyder 3 months ago

  • Status changed from New to AskedReporter

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

#2 Updated by Aria Kraft 3 months ago

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.

#3 Updated by Lloyd Gomez 3 months ago

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) 

#4 Updated by Wilson Snyder 3 months ago

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

https:/msg153502.html

#5 Updated by Lloyd Gomez 3 months ago

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.

#6 Updated by Wilson Snyder 3 months ago

  • Status changed from AskedReporter to NoFixNeeded

Glad it is working now.

#7 Updated by Affe Mao 23 days ago

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);
doesn't work, but
is.getline(&linebuf[0],1000,'\n');

works.

Is that because Cygwin's Stdc++ library requires an more strict initialization of
string line;
?

Cheers~

#8 Updated by Wilson Snyder 22 days ago

  • Status changed from NoFixNeeded to Assigned

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.

#9 Updated by Wilson Snyder 21 days ago

  • Subject changed from Verilator 4.002 install on Cygwin fails during "make test" to Cygwin verilator_coverage fails due to cygwin bug in getline()
  • Status changed from Assigned to Resolved

Thanks for the patch.

Work around added to git towards 4.008.

#10 Updated by Wilson Snyder 16 days ago

  • Status changed from Resolved to Closed

In 4.008.

Also available in: Atom