IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 20 years ago

Closed 20 years ago

Last modified 20 years ago

#683 closed defect (fixed)

Memory bugs

Reported by: Paul Price Owned by: robert.desonia@…
Priority: high Milestone:
Component: sys Version: unspecified
Severity: normal Keywords:
Cc:

Description

psMemIncrRefCounter should include a check for the allocation callback (helpful
for tracing down memory leaks).

psMetatadataLookupStr and psMetadataLookupMD return a ptr that has to be
psFree-ed by the user, contrary to the policy for the other functions (resulting
in memory leaks). We need to settle on a consistent policy for lookup-type
functions within pslib, but for the time being, we should remove the incremented
reference counter on these functions.

Change History (6)

comment:1 by Paul Price, 20 years ago

Here's fixed versions of the psMetadataLookupStr and psMetadataLookupMD:

psMetadata *psMetadataLookupMD(bool *status,

const psMetadata *md,
const char *key)

{

psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); The

metadata with instruments

psMetadata *value = NULL; The value to return
if (!item) {

The given key isn't in the metadata
if (status) {

*status = false;

} else {

psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n");

}

} else if (item->type != PS_DATA_METADATA) {

The value at the key isn't metadata
if (status) {

*status = false;

} else {

psLogMsg(func, PS_LOG_WARN, "%s isn't of type PS_DATA_META, as

expected.\n");

}
value = NULL;

} else {

We have the requested metadata
if (status) {

*status = true;

}
value = item->data.md; The requested metadata

}
return value;

}

psString psMetadataLookupStr(bool *status,

const psMetadata *md,
const char *key)

{

psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); The

metadata with instruments

char *value = NULL; The value to return
psString value = NULL;
if (!item) {

The given key isn't in the metadata
if (status) {

*status = false;

} else {

psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n");

}

} else if (item->type != PS_DATA_STRING) {

The value at the key isn't of the desired type
if (status) {

*status = false;

} else {

psLogMsg(func, PS_LOG_WARN, "%s isn't of type PS_DATA_STRING, as

expected.\n");

}
value = NULL;

} else {

We have the requested metadata
if (status) {

*status = true;

}
value = item->data.V;

}
return value;

}

comment:2 by Paul Price, 20 years ago

And psMemIncrRefCounter:

increment and return refCounter
psPtr p_psMemIncrRefCounter(psPtr vptr,

const char *file,
psS32 lineno)

{

psMemBlock* ptr;

if (vptr == NULL) {

return vptr;

}

ptr = ((psMemBlock* ) vptr) - 1;

if (checkMemBlock(ptr, func)) {

memProblemCallback(ptr, file, lineno);

}

pthread_mutex_lock(&ptr->refCounterMutex);
ptr->refCounter++;
pthread_mutex_unlock(&ptr->refCounterMutex);

Did the user ask to be informed about this allocation?
if (ptr->id == p_psMemAllocID) {

p_psMemAllocID += memAllocCallback(ptr);

}

return vptr;

}

comment:3 by gusciora@…, 20 years ago

Owner: changed from gusciora@… to robert.desonia@…

comment:4 by robert.desonia@…, 20 years ago

Resolution: fixed
Status: newclosed

made changes to psMetadataLookupPtr, psMetadataLookupStr, and psMetadataLookupMD to remove the
memory reference increment. Also searched and changed any code using these functions.

Also added the change to p_psMemIncrRefCounter as suggested.

-rdd

comment:5 by Paul Price, 20 years ago

Keywords: VERIFIED added

Bug has been resolved.... closing.

comment:6 by Paul Price, 20 years ago

Keywords: VERIFIED removed

Bugs have been fixed... closing.

Note: See TracTickets for help on using tickets.