Comments (4)
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.
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.
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)
- Build without static is broken HOT 4
- decoder/docs/html not published HOT 1
- opencsd and linux kernel version HOT 3
- Default error logger does not output to stderr as stated in prog_guide_main.md HOT 1
- prog_guide_main.md should state that createMemAccMapper() should be called before adding memory images HOT 1
- `perf` require massive mmap area when using `tmc_etr0` HOT 1
- perf trace data decoding failed HOT 1
- Q: Can I get errors for inconsistencies between trace and binary? HOT 5
- Using OpenCSD with Android target? HOT 1
- makefile is not tolerant of a path with spaces (OCSD_ROOT/awk script need quotes) HOT 1
- Invalid index check while processing Waypoint Update packet for PTM HOT 3
- Out of bound Read found in TraceFmtDcdImpl::extractFrame() HOT 5
- Out of bound Read found in TraceFmtDcdImpl::extractFrame() HOT 1
- Out of bound Read & Write found in TraceFmtDcdImpl::unpackFrame() HOT 2
- Memory leak in EtmV4P0Stack::createAddrElem HOT 2
- Use after free in TrcPktDecodeEtmV4I::mispredictAtom HOT 3
- Multithreaded Decoding HOT 2
- ETMv4 Exception Target Hand-Over HOT 3
- How to use HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencsd.