Skip to content

odb: Memory leak when using beginEco/commitEco #9422

@b-chmiel

Description

@b-chmiel

Describe the bug

Valgrind run with ctest detected memory leak in:

  • rsz.recover_power_verbose.tcl,
  • rsz.repair_fanout7_skip_pin_swap.tcl,
  • repair_setup_vt_swap.tcl,
  • repair_fanout7_multi.tcl
    and other rsz tests that use odb::dbDatabase::beginEco call.

Expected Behavior

Memory should be freed.

Environment

-- OpenROAD version: 26Q1-804-ge5b9e6c5b6
-- System name: Linux
-- Compiler: Clang 17.0.6
-- Build type: Debug
-- Install prefix: /@projects/OpenROAD-flow-scripts/tools/install/OpenROAD
-- C++ Standard: 20
-- C++ Standard Required: ON
-- C++ Extensions: OFF
-- LTO/IPO is disabled
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17 - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17 - Success
-- TCL library: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/lib/libtcl.so
-- TCL header: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/include/tcl.h
-- TCL readline library: /nix/store/0fgyw7vmlwji3qsksym50xvy8l1jn04d-tclreadline-2.3.8/lib/libtclreadline.so
-- TCL readline header: /nix/store/0fgyw7vmlwji3qsksym50xvy8l1jn04d-tclreadline-2.3.8/include
-- Found SWIG: /nix/store/gaff0j5xphxxrsh9920wmrkzysi9x0yc-swig-4.0.2/bin/swig (found suitable version "4.0.2", minimum required is "4.0")
-- boost: 1.83.0
-- GTest: 1.14.0
-- Address Sanitizer is enabled
-- spdlog: 1.13.0
-- STA version: 2.7.0
-- STA git sha: 087793e8a0c0245d0b696039c638acad425fbf66
-- System name: Linux
-- Compiler: Clang 17.0.6
-- Build type: Debug
-- Build CXX_FLAGS: 
-- Install prefix: /@projects/OpenROAD-flow-scripts/tools/install/OpenROAD
-- TCL library: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/lib/libtcl.so
-- TCL header: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/include/tcl.h
-- TCL readline library: /nix/store/0fgyw7vmlwji3qsksym50xvy8l1jn04d-tclreadline-2.3.8/lib/libtclreadline.so
-- TCL readline header: /nix/store/0fgyw7vmlwji3qsksym50xvy8l1jn04d-tclreadline-2.3.8/include/tclreadline.h
-- CUDD library: /nix/store/0lvhd80c45rjzmnlpx3qnxapl09j6ply-cudd-3.0.0/lib/libcudd.a
-- CUDD header: /nix/store/0lvhd80c45rjzmnlpx3qnxapl09j6ply-cudd-3.0.0/include/cudd.h
-- SSTA: 0
-- Found SWIG: /nix/store/gaff0j5xphxxrsh9920wmrkzysi9x0yc-swig-4.0.2/bin/swig (found suitable version "4.0.2", minimum required is "3.0")
-- STA library: /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/libOpenSTA.a
-- STA executable: /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/sta
-- Found OR-Tools: /opt/or-tools/lib/cmake/ortools (version: 9.11.4210)
-- TCL library: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/lib/libtcl.so
-- TCL header: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/include/tcl.h
-- Found OpenMP: TRUE (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1")
-- GUI is not enabled
-- Could NOT find VTune (missing: VTune_LIBRARIES VTune_INCLUDE_DIRS) 
-- TCL library: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/lib/libtcl.so
-- TCL header: /nix/store/mgh5p3avp1hz5rv1z43j8zwp4j58cdxm-tcl-8.6.13/include/tcl.h
-- TCL readline enabled
-- Tcl Extended disabled
-- Python3 enabled
-- Configuring done (5.6s)
-- Generating done (2.5s)
-- Build files have been written to: /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build

To Reproduce

cmake -B build -S . \
	-DBUILD_GUI=OFF \
	-DUSE_SYSTEM_BOOST:BOOL=ON \
	-DSPDLOG_FMT_EXTERNAL=OFF \
	-DCMAKE_BUILD_TYPE=Debug \
	-DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer -Wno-c++11-narrowing" \
	-DCMAKE_C_FLAGS="-fno-omit-frame-pointer -fno-pie -no-pie" \
	-DFMT_CONSTEVAL="" \
	-DBOOST_STACKTRACE_USE_ADDR2LINE=1 \
	-DBOOST_STACKTRACE_LINK=1 \
	-DASAN=ON \
	-DPython3_EXECUTABLE=$(which python3) \
	-DPython3_INCLUDE_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'))") \
	-DPython3_LIBRARY=$(find $(python3 -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -name libpython3*.so)

ctest --test-dir build  --output-on-failure -R "recover_power_verbose"

Error log attached.

error.log

Relevant log output

=================================================================
==3457565==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 240 byte(s) in 3 object(s) allocated from:
    #0 0x5555570337a8 in operator new(unsigned long) (/@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/bin/openroad+0x1adf7a8)
    #1 0x55555cbb8367 in odb::dbDatabase::beginEco(odb::dbBlock*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbDatabase.cpp:740:21
    #2 0x55555b6cd9f6 in rsz::Resizer::journalBegin() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4566:3
    #3 0x55555b799cbc in rsz::RecoverPower::recoverPower(float, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/RecoverPower.cc:115:15
    #4 0x55555b6f763e in rsz::Resizer::recoverPower(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4530:26
    #5 0x5555573bff3a in rsz::recover_power(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:2376:19
    #6 0x5555573bff3a in _wrap_recover_power(void*, Tcl_Interp*, int, Tcl_Obj* const*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:4686:22
    #7 0x7ffff7e28a27 in TclNRRunCallbacks (/nix/store/z1ll61bbc75nclb1lr72xwzbz6cgz9kb-tcl-8.6.16/lib/libtcl.so+0x46a27)

Direct leak of 160 byte(s) in 2 object(s) allocated from:
    #0 0x5555570337a8 in operator new(unsigned long) (/@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/bin/openroad+0x1adf7a8)
    #1 0x55555cbb8367 in odb::dbDatabase::beginEco(odb::dbBlock*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbDatabase.cpp:740:21
    #2 0x55555b6cd9f6 in rsz::Resizer::journalBegin() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4566:3
    #3 0x55555b79a4aa in rsz::RecoverPower::recoverPower(float, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/RecoverPower.cc:165:19
    #4 0x55555b6f763e in rsz::Resizer::recoverPower(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4530:26
    #5 0x5555573bff3a in rsz::recover_power(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:2376:19
    #6 0x5555573bff3a in _wrap_recover_power(void*, Tcl_Interp*, int, Tcl_Obj* const*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:4686:22
    #7 0x7ffff7e28a27 in TclNRRunCallbacks (/nix/store/z1ll61bbc75nclb1lr72xwzbz6cgz9kb-tcl-8.6.16/lib/libtcl.so+0x46a27)

Indirect leak of 256 byte(s) in 2 object(s) allocated from:
    #0 0x555557033908 in operator new[](unsigned long) (/@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/bin/openroad+0x1adf908)
    #1 0x55555ca4eb7d in odb::dbPagedVector<unsigned char, 128u, 7u>::newPage() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbPagedVector.h:214:13
    #2 0x55555ca4d0f5 in odb::dbPagedVector<unsigned char, 128u, 7u>::push_back(unsigned char const&) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbPagedVector.h:233:5
    #3 0x55555ca4d0f5 in odb::dbJournalLog::append(odb::dbJournalLog&) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbJournalLog.cpp:285:13
    #4 0x55555cbb967e in odb::dbDatabase::commitEco(odb::dbBlock*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbDatabase.cpp:777:19
    #5 0x55555b6f7e43 in rsz::Resizer::journalEnd() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4586:3
    #6 0x55555b79a48d in rsz::RecoverPower::recoverPower(float, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/RecoverPower.cc:164:19
    #7 0x55555b6f763e in rsz::Resizer::recoverPower(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4530:26
    #8 0x5555573bff3a in rsz::recover_power(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:2376:19
    #9 0x5555573bff3a in _wrap_recover_power(void*, Tcl_Interp*, int, Tcl_Obj* const*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:4686:22
    #10 0x7ffff7e28a27 in TclNRRunCallbacks (/nix/store/z1ll61bbc75nclb1lr72xwzbz6cgz9kb-tcl-8.6.16/lib/libtcl.so+0x46a27)

Indirect leak of 16 byte(s) in 2 object(s) allocated from:
    #0 0x555557033908 in operator new[](unsigned long) (/@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/bin/openroad+0x1adf908)
    #1 0x55555ca4ec5d in odb::dbPagedVector<unsigned char, 128u, 7u>::newPage() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbPagedVector.h:217:14
    #2 0x55555ca4d0f5 in odb::dbPagedVector<unsigned char, 128u, 7u>::push_back(unsigned char const&) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbPagedVector.h:233:5
    #3 0x55555ca4d0f5 in odb::dbJournalLog::append(odb::dbJournalLog&) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbJournalLog.cpp:285:13
    #4 0x55555cbb967e in odb::dbDatabase::commitEco(odb::dbBlock*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/odb/src/db/dbDatabase.cpp:777:19
    #5 0x55555b6f7e43 in rsz::Resizer::journalEnd() /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4586:3
    #6 0x55555b79a48d in rsz::RecoverPower::recoverPower(float, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/RecoverPower.cc:164:19
    #7 0x55555b6f763e in rsz::Resizer::recoverPower(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/src/rsz/src/Resizer.cc:4530:26
    #8 0x5555573bff3a in rsz::recover_power(float, bool, bool) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:2376:19
    #9 0x5555573bff3a in _wrap_recover_power(void*, Tcl_Interp*, int, Tcl_Obj* const*) /@projects/OpenROAD-flow-scripts/tools/OpenROAD/build/src/rsz/src/CMakeFiles/rsz.dir/ResizerTCL_wrap.cxx:4686:22
    #10 0x7ffff7e28a27 in TclNRRunCallbacks (/nix/store/z1ll61bbc75nclb1lr72xwzbz6cgz9kb-tcl-8.6.16/lib/libtcl.so+0x46a27)

Screenshots

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

rszResizer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions