Code Monkey home page Code Monkey logo

Comments (5)

pmqs avatar pmqs commented on July 3, 2024

Thanks @iabyn,

I thought I'd already run DB_File through Address Sanatizer without finding anything. May have been an older version.

Could you share the Address Sanatizer settings you were using and I'll see if I can reproduce the issue?

from db_file.

iabyn avatar iabyn commented on July 3, 2024

from db_file.

pmqs avatar pmqs commented on July 3, 2024

Thanks @iabyn

from db_file.

pmqs avatar pmqs commented on July 3, 2024

Issue reproduced.

The leak can be triggered by with this code (taken from t/db-btree.t

use blib;
use DB_File;

# check that attempting to tie an array to a DB_BTREE will fail

my $filename = "xyz" ;
my @x ;
tie @x, 'DB_File', $filename, O_RDWR|O_CREAT, 0640, $DB_BTREE ; 
unlink $filename ;

Get this error

=9990==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1456 byte(s) in 1 object(s) allocated from:
    #0 0x7f6146141448 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10c448)
    #1 0x7f614212d774 in __os_malloc (/usr/lib/x86_64-linux-gnu/libdb-5.3.so+0x147774)
    #2 0x61d00005e67f  (<unknown module>)

Indirect leak of 2120 byte(s) in 2 object(s) allocated from:
    #0 0x7f6146141448 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10c448)
    #1 0x7f614212d774 in __os_malloc (/usr/lib/x86_64-linux-gnu/libdb-5.3.so+0x147774)

Indirect leak of 1656 byte(s) in 7 object(s) allocated from:
    #0 0x7f6146141448 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10c448)
    #1 0x7f614212d774 in __os_malloc (/usr/lib/x86_64-linux-gnu/libdb-5.3.so+0x147774)
    #2 0x80967fb4538a37ff  (<unknown module>)

The issue is triggered by code in ParseOpenInfo that first calls db_create without any problem. It then checks that the SV that will be tied to is a reference to the correct type. In the sample code above it triggers this croak_and_free.

    if (!isHASH)
        croak_and_free("DB_File can only tie an associative array to a DB_HASH database") ;

In croak_and_free all the malloc'ed memory should be freed. Issue here is a successful call to db_create needs to then call db_close to free memory that Berkeley DB has allocated behind the scenes, In this case that isn't happening.

from db_file.

pmqs avatar pmqs commented on July 3, 2024

Fix included in DB_File 1.853. Closing issue

from db_file.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.