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

Problem with -DVL_LEAK_CHECKS #521

Closed
veripoolbot opened this issue May 29, 2012 · 2 comments
Closed

Problem with -DVL_LEAK_CHECKS #521

veripoolbot opened this issue May 29, 2012 · 2 comments
Assignees
Labels
resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Jeremy Bennett (@jeremybennett)
Original Redmine Issue: 521 from https://www.veripool.org
Original Date: 2012-05-29
Original Assignee: Wilson Snyder (@wsnyder)


I enabled -DVL_LEAK_CHECKS (by uncommenting the line in src/Makefile_obj.in). Building Verilator failed with:

g++ -I/opt/verilator-HEAD/include -MMD -I. -I.. -I.. -I../../include -DYYDEBUG  -DVL_LEAK_CHECKS         -ggdb -DVL_DEBUG -MP  -DDEFENV_SYSTEMC=\"/opt/systemc\" -DDEFENV_SYSTEMC_ARCH=\"linux\" -DDEFENV_SYSTEMC_INCLUDE=\"\" -DDEFENV_SYSTEMC_LIBDIR=\"\" -DDEFENV_SYSTEMPERL=\"/home/jeremy/tools/veripool/SystemPerl\" -DDEFENV_SYSTEMPERL_INCLUDE=\"/home/jeremy/tools/veripool/SystemPerl/src\" -DDEFENV_VERILATOR_ROOT=\"/opt/verilator-HEAD/share/verilator\" -c ../V3Error.cpp
../V3Error.cpp: In static member function ‘static void FileLine::deleteAllRemaining()’:
../V3Error.cpp:311:30: error: cannot call member function ‘void FileLineSingleton::clear()’ without object

The problem code is:


void FileLine::deleteAllRemaining() {
#ifdef VL_LEAK_CHECKS
     // FileLines are allocated, but never nicely freed, as it's much faster
     // that way.  Unfortunately this makes our leak checking a big mess, so
     // only when leak checking we'll track them all and cleanup.
     while (1) {
	FileLineCheckSet::iterator it=fileLineLeakChecks.begin();
	if (it==fileLineLeakChecks.end()) break;
	delete *it;
	// Operator delete will remove the iterated object from the list.
	// Eventually the list will be empty and terminate the loop.
     }
     fileLineLeakChecks.clear();
     FileLineSingleton::clear();
#endif
}

I believe the final call should be:

     singleton().clear();

With this the code then compiles. Please pull a patch from:

https://github.com/jeremybennett/verilator/tree/valgrind

However the resulting tool chain immediately fails regression test to print out its version information:

make[1]: Entering directory `/home/jeremy/gittrees/verilator/test_c'
/usr/bin/perl /home/jeremy/gittrees/verilator/test_c/../bin/verilator --debug --debugi 0 --gdbbt --no-dump-tree -V
No stack.
         gdb /home/jeremy/gittrees/verilator/test_c/../verilator_bin_dbg --batch --quiet --return-child-result -ex 'run --debug --debugi 0 --gdbbt --no-dump-tree -V' -ex 'set width 0' -ex 'bt'

Program received signal SIGSEGV, Segmentation fault.
0x4161644d in std::_Rb_tree_decrement (__x=0x83921a8) at ../../../../libstdc++-v3/src/tree.cc:91
91          if (__x->_M_color == _S_red 
#0  0x4161644d in std::_Rb_tree_decrement (__x=0x83921a8) at ../../../../libstdc++-v3/src/tree.cc:91
#1  0x080d09d9 in std::_Rb_tree_iterator<std::pair<AstNode const* const, int> >::operator-- (this=0xbfffe8e8) at /usr/lib/gcc/i686-redhat-linux/4.6.3/../../../../include/c++/4.6.3/bits/stl_tree.h:203
#2  0x080d0624 in std::_Rb_tree<AstNode const*, std::pair<AstNode const* const, int>, std::_Select1st<std::pair<AstNode const* const, int> >, std::less<AstNode const*>, std::allocator<std::pair<AstNode const* const, int> > >::_M_insert_unique (this=0x83921a4, __v=...) at /usr/lib/gcc/i686-redhat-linux/4.6.3/../../../../include/c++/4.6.3/bits/stl_tree.h:1287
#3  0x080d0327 in std::map<AstNode const*, int, std::less<AstNode const*>, std::allocator<std::pair<AstNode const* const, int> > >::insert (this=0x83921a4, __x=...) at /usr/lib/gcc/i686-redhat-linux/4.6.3/../../../../include/c++/4.6.3/bits/stl_map.h:518
#4  0x080cf21e in BrokenTable::addNewed (nodep=0x83931c8) at ../V3Broken.cpp:74
#5  0x080cee19 in V3Broken::addNewed (nodep=0x83931c8) at ../V3Broken.cpp:262
#6  0x080bb5e4 in AstNode::operator new (size=108) at ../V3Ast.cpp:724
#7  0x080a5af8 in V3Global::makeNetlist (this=0x8392000) at ../Verilator.cpp:98
#8  0x080aa5c3 in V3Global::V3Global (this=0x8392000) at ../V3Global.h:64
#9  0x080aa313 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../Verilator.cpp:92
#10 0x080aa34c in _GLOBAL__sub_I_v3Global () at ../Verilator.cpp:696
#11 0x0823ea52 in __libc_csu_init ()
#12 0x4d0a764a in __libc_start_main (main=0x80a962f <main(int, char**, char**)>, argc=7, ubp_av=0xbfffeb34, init=0x823ea00 <__libc_csu_init>, fini=0x823ea70 <__libc_csu_fini>, rtld_fini=0x4d0792c0 <_dl_fini>, stack_end=0xbfffeb2c) at libc-start.c:185
#13 0x0804b251 in _start ()
%Error: export VERILATOR_ROOT=/home/jeremy/gittrees/verilator/test_c/..
%Error: gdb /home/jeremy/gittrees/verilator/test_c/../verilator_bin_dbg --batch --quiet --return-child-result -ex 'run --debug --debugi 0 --gdbbt --no-dump-tree -V' -ex 'set width 0' -ex 'bt'
%Error: Command Failed gdb /home/jeremy/gittrees/verilator/test_c/../verilator_bin_dbg --batch --quiet --return-child-result -ex 'run --debug --debugi 0 --gdbbt --no-dump-tree -V' -ex 'set width 0' -ex 'bt'
make[1]: *** [show_config] Error 255
make[1]: Leaving directory `/home/jeremy/gittrees/verilator/test_c'
make: *** [test_c] Error 2


I can't yet work out the cause, but it is connected to the setting of VERILATOR_ROOT. If I run the same command from the command line without VERILATOR_ROOT set, it works without any problem. If VERILATOR_ROOT is set, I get the SEGV.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-05-30T02:59:27Z


This is fixed in git, the core dump was due to recent changes for structs.

The check does report many leaks though which at first glance is also struct related, I'll clean them up.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-05-31T03:19:35Z


Fixed most leaks (rest should go away when other features go in).

When compiled with VL_LEAK_CHECKS, --debug-check will now enable the runtime test, so that --debug isn't required.

BTW I didn't see anything that would be V3Order - performance/memory related. However the leak checks aren't graph focused.

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

No branches or pull requests

2 participants