Giter Club home page Giter Club logo

Comments (4)

mikel-armbb avatar mikel-armbb commented on August 15, 2024

Hi,

You are correct in that setGenTraceElemOutI() needs to store:
m_i_gen_elem_out = i_gen_trace_elem;

but the client must test and delete the object.
In this case the C-API handler code must test for a current set interface and delete a GenTraceElemCBObj if found

Mike

from opencsd.

holio0 avatar holio0 commented on August 15, 2024

Hi Mike,

In my usage the client is the caller of ocsd_dt_set_gen_elem_outfn and ocsd_destroy_dcd_tree defined in opencsd_c_api.h. The ocsd_dt_set_gen_elem_outfn allocates a GenTraceElemCBObj instance for function setGenTraceElemOutI:

OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_outfn(const dcd_tree_handle_t handle, FnTraceElemIn pFn, const void *p_context)
{

    GenTraceElemCBObj * pCBObj = new (std::nothrow)GenTraceElemCBObj(pFn, p_context);
    if(pCBObj)
    {
        ((DecodeTree *)handle)->setGenTraceElemOutI(pCBObj);

But without assigning it to m_i_gen_elem_out, the GenTraceElemCBObj object cannot be released by ocsd_destroy_dcd_tree. That is, following usage can reproduce the leakage:

dcd_tree_handle_t dcdtree_handle;

dcdtree_handle = ocsd_create_dcd_tree(...);
ocsd_dt_set_gen_elem_outfn(dcdtree_handle, ...);
ocsd_destroy_dcd_tree(dcdtree_handle)

dcdtree_handle = ocsd_create_dcd_tree(...);
ocsd_dt_set_gen_elem_outfn(dcdtree_handle, ...);
ocsd_destroy_dcd_tree(dcdtree_handle);

And seems for such a caller, the opencsd_c_api.h doesn't expose a C-API to access and delete the GenTraceElemCBObj directly?

from opencsd.

mikel-armbb avatar mikel-armbb commented on August 15, 2024

The assignment of :-
m_i_gen_elem_out = i_gen_trace_elem;
occurs in ocsd_dcd_tree.cpp -> DecodeTree::setGenTraceElemOutI(),

A check for a previous assignment an release of the old GenTraceElemCBObj must then take place in ocsd_c_api.cpp -> ocsd_dt_set_gen_elem_outfn() before any new object is allocated.

Thus the creation and destruction of these internal C-API layer objects takes place in the same area of code.

This will be fixed in the next release of the library

from opencsd.

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.