397832 - libpkix leaks memory if a macro calls a function that returns an error. Object leak test changes for tinderbox (attachment 315629). r=nelson
git-svn-id: svn://10.0.0.236/trunk@250276 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e215d81927
commit
1297906c06
@ -85,6 +85,8 @@ pkix_pl_lifecycle_ObjectTableUpdate(int *objCountTable);
|
||||
|
||||
PRInt32 parallelFnInvocationCount;
|
||||
|
||||
PRInt32 stackErrorCodes[MAX_STACK_DEPTH];
|
||||
|
||||
#endif /* PKIX_OBJECT_LEAK_TEST */
|
||||
|
||||
|
||||
@ -841,17 +843,23 @@ cert_PkixErrorToNssCode(
|
||||
/* Loop until we find at least one error with non-null
|
||||
* plErr code, that is going to be nss error code. */
|
||||
while (errPtr) {
|
||||
#ifdef PKIX_OBJECT_LEAK_TEST
|
||||
stackErrorCodes[errLevel] = errPtr->errCode;
|
||||
#endif
|
||||
if (errPtr->plErr && !nssErr) {
|
||||
nssErr = errPtr->plErr;
|
||||
if (!pkixLog) break;
|
||||
}
|
||||
if (pkixLog) {
|
||||
PR_LOG(pkixLog, 1, ("Error at level %d: %s\n", errLevel,
|
||||
PR_LOG(pkixLog, 2, ("Error at level %d: %s\n", errLevel,
|
||||
PKIX_ErrorText[errPtr->errCode]));
|
||||
}
|
||||
errPtr = errPtr->cause;
|
||||
errLevel += 1;
|
||||
}
|
||||
#ifdef PKIX_OBJECT_LEAK_TEST
|
||||
stackErrorCodes[errLevel] = -1;
|
||||
#endif
|
||||
PORT_Assert(nssErr);
|
||||
if (!nssErr) {
|
||||
*pNssErr = SEC_ERROR_LIBPKIX_INTERNAL;
|
||||
@ -1020,9 +1028,6 @@ cert_GetBuildResults(
|
||||
fprintf(stderr, "BUILD ERROR:\n%s\n", temp);
|
||||
PKIX_PL_Free(temp, NULL);
|
||||
#endif /* DEBUG */
|
||||
cert_PkixErrorToNssCode(error, &nssErrorCode, plContext);
|
||||
PORT_SetError(nssErrorCode);
|
||||
|
||||
if (verifyNode) {
|
||||
PKIX_Error *tmpError =
|
||||
cert_GetLogFromVerifyNode(log, verifyNode, plContext);
|
||||
@ -1030,6 +1035,8 @@ cert_GetBuildResults(
|
||||
PKIX_PL_Object_DecRef((PKIX_PL_Object *)tmpError, plContext);
|
||||
}
|
||||
}
|
||||
cert_PkixErrorToNssCode(error, &nssErrorCode, plContext);
|
||||
PORT_SetError(nssErrorCode);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1276,6 +1283,14 @@ cleanup:
|
||||
leakedObjNum =
|
||||
pkix_pl_lifecycle_ObjectLeakCheck(leakedObjNum ? objCountTable : NULL);
|
||||
|
||||
if (pkixLog && leakedObjNum) {
|
||||
int level = 0;
|
||||
PR_LOG(pkixLog, 1, ("The following error caused object leaks:\n"));
|
||||
for(;level < MAX_STACK_DEPTH && stackErrorCodes[level] != -1;level++) {
|
||||
PR_LOG(pkixLog, 1, ("Error at level %d: %s\n", level,
|
||||
PKIX_ErrorText[stackErrorCodes[level]]));
|
||||
}
|
||||
}
|
||||
if (abortOnLeak) {
|
||||
PORT_Assert(leakedObjNum == 0);
|
||||
}
|
||||
@ -2234,6 +2249,15 @@ cleanup:
|
||||
leakedObjNum =
|
||||
pkix_pl_lifecycle_ObjectLeakCheck(leakedObjNum ? objCountTable : NULL);
|
||||
|
||||
if (pkixLog && leakedObjNum) {
|
||||
int level = 0;
|
||||
|
||||
PR_LOG(pkixLog, 1, ("The following error caused object leaks:\n"));
|
||||
for(;level < MAX_STACK_DEPTH && stackErrorCodes[level] != -1;level++) {
|
||||
PR_LOG(pkixLog, 1, ("Error at level %d: %s\n", level,
|
||||
PKIX_ErrorText[stackErrorCodes[level]]));
|
||||
}
|
||||
}
|
||||
if (abortOnLeak) {
|
||||
PORT_Assert(leakedObjNum == 0);
|
||||
}
|
||||
@ -2246,4 +2270,3 @@ cleanup:
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,6 @@ extern PLHashNumber PR_CALLBACK pkix_ErrorGen_Hash (const void *key);
|
||||
funcName, &errorSetFlag, \
|
||||
plContext); \
|
||||
if (pkixErrorResult) { \
|
||||
printf("Error in fn: %s\n", myFuncName); \
|
||||
PR_LOG(pkixLog, 5, \
|
||||
("%s%*s<- %s(%d) - %s\n", (errorGenerated ? "*" : " "), \
|
||||
stackPosition, " ", fnStackNameArr[stackPosition], \
|
||||
|
||||
@ -206,7 +206,7 @@ libpkix_setup_db()
|
||||
echo "Loading certs into DB at $DB_DIR"
|
||||
output=$TMP/libpkix_setup.tmp
|
||||
while read certName trusts; do
|
||||
certutil -d $DB_DIR -A -n $certName -t $trusts -i $CERT_DIR/$certName.cert > $output 2>&1
|
||||
certutil -d $DB_DIR -A -n $certName -t $trusts -i $CERT_DIR/$certName.cert -f "${R_PWFILE}" > $output 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "WARNING: unable to add a certificate($certName) into database"
|
||||
echo "certutil output:"
|
||||
@ -243,14 +243,14 @@ libpkix_leak_test()
|
||||
[ $status -ne 0 ] && continue;
|
||||
extraOpt=""
|
||||
if [ "$explPolicy" -a "$explPolicy" != "undef" ]; then
|
||||
extraOpt="-p -o $explPolicy"
|
||||
extraOpt="-pp -o $explPolicy"
|
||||
fi
|
||||
cmd="vfychain -d $DB_DIR $extraOpt $CERT_DIR/$leafCert.cert"
|
||||
if [ -n "$MEMLEAK_DBG" ]; then
|
||||
cmd="$RUN_COMMAND_DBG $cmd"
|
||||
fi
|
||||
echo $cmd
|
||||
$cmd > $tmpLogFile
|
||||
$cmd > $tmpLogFile 2>&1
|
||||
if [ -z "$MEMLEAK_DBG" ]; then
|
||||
cat $tmpLogFile
|
||||
grep "Memory Leak:" $tmpLogFile
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user