Coder Social home page Coder Social logo

Comments (2)

daedric avatar daedric commented on May 29, 2024
as_record* rec = as_record_new(1);
{
    as_arraylist l;
    as_arraylist_init(&l, 1, 0);

    as_string* str = as_string_new_strdup("Hello world");
    as_arraylist_append_string(&l, str);
    as_record_set_list(rec, "list", (as_list*)as_val_reserve((as_val*)&l));
    as_arraylist_destroy(&l);
}
{
    as_arraylist l;
    as_arraylist_init(&l, 1, 0);

    as_string* str = as_string_new_strdup("Hello world");
    as_arraylist_append_string(&l, str);
    as_record_set_list(rec, "list", (as_list*)as_val_reserve((as_val*)&l));
    as_arraylist_destroy(&l);
}

as_record_destroy(rec);

Here is the sanitizer output:

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6054c979a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
    #1 0x6c744f in as_arraylist_init aerospike-client-c/modules/common/src/main/aerospike/as_arraylist.c:51

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6054c9602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x6cc676 in as_string_new aerospike-client-c/modules/common/src/main/aerospike/as_string.c:49
    #2 0x6cc676 in as_string_new_strdup aerospike-client-c/modules/common/src/main/aerospike/as_string.c:61

Indirect leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6054c9602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7ff6039eaa59 in __strdup (/lib/x86_64-linux-gnu/libc.so.6+0x8aa59)

SUMMARY: AddressSanitizer: 52 byte(s) leaked in 3 allocation(s).

from aerospike-client-c.

daedric avatar daedric commented on May 29, 2024

Ok I found the problem. Actually I assumed that the content of the list was somehow kept despite the actual struct being on the stack (the as_list could have been a pointer allocated upon as_arraylist_init), however this is not the case so the library was actually trying to destroy the valuep but it was not pointing anywhere valid.

from aerospike-client-c.

Related Issues (20)

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.