Skip to content

Small memory leak when BerkeleyEnvironment::Open fails #19034

@ryanofsky

Description

@ryanofsky

Originally reported #18907 (comment)

This happens when trying to load a wallet with corrupt logs. It can be reproduced running the wallet_db.py test from #18907@c6a2c26. From https://travis-ci.org/github/bitcoin/bitcoin/jobs/689013660#L4659:

==2504==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 65840 byte(s) in 2 object(s) allocated from:
    #0 0x55b144d4adb3 in __interceptor_malloc (/home/travis/build/bitcoin/bitcoin/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/bitcoind+0x1c75db3)
    #1 0x7f0207036cc4 in __os_malloc (/usr/lib/x86_64-linux-gnu/libdb_cxx-5.3.so+0x162cc4)
    #2 0x19f3b1afb25218ff  (<unknown module>)
SUMMARY: AddressSanitizer: 65840 byte(s) leaked in 2 allocation(s). 

The leak is known to happen at commits 274b990 (initial commit) and e78c682 (attempted fix) from #18907

This is probaby not a very severe issue, but it'd be good to track down the leak, fix it, and add the wallet_db test to have some test coverage for log recovery. All of this can be done independently of #18907, before or after it is merged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions