Closed Bug 317856 Opened 19 years ago Closed 19 years ago

uninitialized variables in strsclnt.c

Categories

(NSS :: Tools, defect, P2)

3.11
x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.11.1

People

(Reporter: wolfiR, Assigned: julien.pierre)

Details

Attachments

(1 file, 2 obsolete files)

strsclnt.c: In function 'launch_thread':
strsclnt.c:500: warning: 'i' is used uninitialized in this function
strsclnt.c: In function 'do_connects':
strsclnt.c:846: warning: 'now' is used uninitialized in this function

The first one is just used for a printf and not critical. I'm not sure for the second:
PRTime now;
PR_Lock(threadLock);
lastConnectSuccess = PR_MAX(now, lastConnectSuccess);

This seems broken to me at first glance.
Wolfgang, thanks for the bug report.

These bugs were introduced by the fix for bug 292151
in NSS 3.11.  The fix should be:
1. remove 'i'.  It probably should be replaced by 'numUsed-1'
   or 'numUsed' in the PRINTF statement.  The message
   "strsclnt: Launched thread in slot %d \n" may need to be
   updated to describe the new code (if the new code no longer
   uses slots).
2. initialize 'now' with PR_Now().
Assignee: wtchang → julien.pierre.bugs
Priority: -- → P1
Target Milestone: --- → 3.11.1
Attached patch fix as checked in to the tip (obsolete) — Splinter Review
These are the fixes suggested by Wan-Teh, and they are correct.
Checking in strsclnt.c;
/cvsroot/mozilla/security/nss/cmd/strsclnt/strsclnt.c,v  <--  strsclnt.c
new revision: 1.45; previous revision: 1.44
done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Changing priority. This is P2, not P1 . Target is 3.12 .
Status: RESOLVED → VERIFIED
Priority: P1 → P2
Target Milestone: 3.11.1 → 3.12
Julien, strsclnt is used in our test suite to determine
whether a build passes QA.  Also, we usually fix all the
compiler warnings in the libraries and the important
commands, but we didn't do that before the 3.11 release.
So your fix should be checked into the NSS_3_11_BRANCH
for 3.11.1.
I meant to say that
  we usually fix all the compiler warnings in the
  libraries and the important commands *before each
  minor release*, ...
OK, I checked it in on the NSS_3_11_BRANCH :

Checking in strsclnt.c;
/cvsroot/mozilla/security/nss/cmd/strsclnt/strsclnt.c,v  <--  strsclnt.c
new revision: 1.43.2.1; previous revision: 1.43
done
Target Milestone: 3.12 → 3.11.1
Comment on attachment 209037 [details] [diff] [review]
fix as checked in to the tip

Julien,

I found that numUsed should only be used while holding
threadLock, so I suggest a different fix for "i".

We should keep "i".  Do not initialize it.

Set "i" here:

+     i = numUsed;
      slot = &threads[numUsed++];

And continue to use "i" in the PRINTF statement, which is
executed after we unlock threadLock.

      slot->inUse   = 1;
      PR_Unlock(threadLock);
      PRINTF("strsclnt: Launched thread in slot %d \n", i);
                                                       ^^^
Attachment #209037 - Flags: review-
Attached patch Patch v2 (obsolete) — Splinter Review
Attachment #209037 - Attachment is obsolete: true
Attachment #209044 - Flags: review?(julien.pierre.bugs)
Attachment #209044 - Attachment is obsolete: true
Attachment #209045 - Flags: review?(julien.pierre.bugs)
Attachment #209044 - Flags: review?(julien.pierre.bugs)
reopened in light of most recent comments.
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
Comment on attachment 209045 [details] [diff] [review]
Patch v2 (corrected)

Indeed, thanks for catching this. I have checked the corrections to both the tip and the 3.11 branch.

Checking in strsclnt.c;
/cvsroot/mozilla/security/nss/cmd/strsclnt/strsclnt.c,v  <--  strsclnt.c
new revision: 1.46; previous revision: 1.45


Checking in strsclnt.c;
/cvsroot/mozilla/security/nss/cmd/strsclnt/strsclnt.c,v  <--  strsclnt.c
new revision: 1.43.2.2; previous revision: 1.43.2.1
done
Attachment #209045 - Flags: review?(julien.pierre.bugs) → review+
Status: REOPENED → RESOLVED
Closed: 19 years ago19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: