Numerous places where uninitialized variables might be being used before being set.

RESOLVED FIXED

Status

Core Graveyard
Tracking
P3
normal
RESOLVED FIXED
17 years ago
a year ago

People

(Reporter: Rich Burridge, Assigned: Atul Aggarwal)

Tracking

(Blocks: 1 bug, {meta})

Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments, 9 obsolete attachments)

37.07 KB, text/plain
Details
4.00 KB, text/plain
Details
1.38 KB, patch
Alec Flett
: superreview+
Details | Diff | Splinter Review
14.40 KB, text/plain
Details
(Reporter)

Description

17 years ago
We have seen a couple of bugs (58698 and 59617) where crashes have
resulted because variables have been used without being previously
initialized.

By building Mozilla (with mail/news) with the -Wuninitialized flag 
and with optimization turned on, I was able to find 192 occurances 
of this in total (in 109 files).

These problems could be the cause of many "random" crashes on platforms 
which don't automatically initialize local variables to zero (Solaris 
being one of them).

See the first attachment, which contains the compile transcript for all
of these 109 files. 

Even though Netscape 6 RTM is almost out the door, we would like to fix 
up these problems for our Solaris Netscape 6 RTM/FCS release, so if diffs 
could be attached to this bug for the various fixes (note the bugs 58698 
and 59617 already contain two such sets of diffs), then it would be very 
much appreciated. 

Thanks.
(Reporter)

Comment 1

17 years ago
Created attachment 19017 [details]
Compile transcript of the 109 files with uninitialized variables.

Comment 2

17 years ago
The best would be if you could split the log between different modules and file
a bug for each. My experience of bugs like this that covers many components is
that noone takes it on.
(Reporter)

Comment 3

17 years ago
Created attachment 19018 [details]
Just the lines that contain the uninitialized variable warnings.
(Reporter)

Comment 4

17 years ago
I've open a load of individual bugs in various modules for this problem.
Hopefully that will inspire the module owners to create diffs for the
files that they own. These are:

59657 - XPCOM
59658 - XPCOM / Registry
59659 - JavaScript Engine
59661 - Networking
59664 - Security / General
59666 - Internationalization
59667 - Imagelib
59670 - Installer
59668 - GTX Embedding
59669 - HTML Element
59673 - Mail / News
59675 - Layout
59676 - XPToolkit / Widgets
59677 - DOM
59678 - Viewer
58698 - Editor

The following lines still need to have individual module bugs filed against
them. I'll do this tomorrow. If anybody can tell me the modules, I'd be
very grateful.

/db/mork/src/morkAtom.cpp
morkAtom.cpp:363: warning: `const mork_u1 * body' might be used uninitialized in
this function
morkAtom.cpp:407: warning: `mork_size size' might be used uninitialized in this
morkAtom.cpp:408: warning: `mork_cscode form' might be used uninitialized in
this function
morkAtom.cpp:432: warning: `mork_size thisSize' might be used uninitialized in
this function
morkAtom.cpp:433: warning: `mork_cscode thisForm' might be used uninitialized in
this function
----
/rdf/base/src/nsRDFContentSink.cpp
nsRDFContentSink.cpp:538: warning: `nsresult rv' might be used uninitialized in
----
/rdf/content/src/nsXULSortService.cpp
nsXULSortService.cpp:1416: warning: `nsresult rv' might be used uninitialized in
this function
----
/docshell/base/nsDocShell.cpp
nsDocShell.cpp:2114: warning: `PRInt32 x' might be used uninitialized in this
function
nsDocShell.cpp:2115: warning: `PRInt32 y' might be used uninitialized in this
function
----
/xpfe/appshell/src/nsWindowMediator.cpp
nsWindowMediator.cpp:676: warning: `struct nsWindowInfo * info' might be used
uninitialized in this function
nsWindowMediator.cpp:678: warning: `PRBool found' might be used uninitialized in
this function
nsWindowMediator.cpp:805: warning: `struct nsWindowInfo * belowInfo' might be
used uninitialized in this function
----
/xpfe/components/search/src/nsInternetSearchService.cpp
nsInternetSearchService.cpp:4082: warning: `PRUnichar quoteChar' might be used
uninitialized in this function
../../../../dist/include/nsAReadableString.h:1085: warning: `int whichString'
might be used uninitialized in this function
----
/extensions/cookie/nsCookie.cpp
nsCookie.cpp:397: warning: `PRInt32 typeIndex' might be used uninitialized in
this function
nsCookie.cpp:1251: warning: `struct permission_HostStruct * hostStruct' might be
used uninitialized in this function
----
/extensions/wallet/src/singsign.cpp
singsign.cpp:1900: warning: `class si_SignonDataStruct * data' might be used
uninitialized in this function
----


I'm not sure about modules, but you should assign the

db/mork stuff to bienvenu
extensions/wallet to morse
docshell to adamlock

Comment 6

17 years ago
[tracking] bug
Summary: Numerous places where uninitialized variables must be being used before being set. → [TRACKING] Numerous places where uninitialized variables must be being used before being set.
(Reporter)

Comment 7

17 years ago
Thanks Seth. I've added bienvenu, morse and adamlock to the CC: of this
bug. I've already opened up enough others bugs for this one. Guys,
with reference to the previous comment by Seth, could you please
attach diifs (assuming they are needed), to fix the uninitialized
variables for the files that you own? Thanks.

Comment 8

17 years ago
Besides the extensions/wallet/singsign.cpp cases, I'm also responsible for the 
one in extensions/cookie/nsCookie.cpp.

I just checked the two cases in singsign and the one case in nsCookie and none 
are a problem.  Here's why (same reason in all three cases).

It's true that the variables in question are not initialized when declared but 
rather are initialized inside a loop.  They are then used after the loop 
terminates.  So the compiler would have no way of knowing if the loop was ever 
executed and therefore considers these as potentially uninitialized.

However, inside the loop another variable changes value.  And after the loop, a 
test is made for that variable changing value and the routine is exited if it 
didn't happen.  Therefore the place that the questionable variable is used 
will never get executed if the loop had never been entered.

Bottom line -- there is no problem here in the nsCookie or singsign files.

Comment 9

17 years ago
Correction: Above I said the two cases in singsign and one in nsCookie.  That 
should read the other way around -- one case in singsign and two in nsCookie.
morse:  you should still fix the warnings to get the off the radar.

Updated

17 years ago
Assignee: asa → chofmann
Component: Browser-General → Tracking
Keywords: meta
QA Contact: doronr → chofmann
Summary: [TRACKING] Numerous places where uninitialized variables must be being used before being set. → Numerous places where uninitialized variables must be being used before being set.

Comment 11

17 years ago
-> tracking

Comment 12

17 years ago
Added attachment that contains comments regarding the warnings.

Comment 13

17 years ago
Created attachment 20372 [details]
comments on warnings
Created attachment 20388 [details]
my comments after *** prefixes, only on herbie's js comments

Comment 15

17 years ago
Changed summary to reflect what the warnings really say.
Summary: Numerous places where uninitialized variables must be being used before being set. → Numerous places where uninitialized variables might be being used before being set.
Cc'ing mang for advice on the fdlibm warnings and scary-looking unbraced but
indented as if written in Python code.  From my attachment:

 e_asin.c:110: warning: `t' might be used uninitialized in this function
   - will get assigned before use.

   *** Agreed, but the indentation without bracing at lines 125-129 looks very
   *** wrong.  This fdlibm code originated from sun.com, could you please see
   *** whether a bug needs to be filed there?  Thanks.

   e_exp.c:143: warning: `hi' might be used uninitialized in this function
   e_exp.c:143: warning: `lo' might be used uninitialized in this function
   e_exp.c:144: warning: `k' might be used uninitialized in this function
   - might need to be init.  possible to get used without first setting.

   *** agreed, these are bugs.  This fdlibm code originated from sun.com, can
   *** you see whether a bug needs to be filed there?  Thanks.

   e_rem_pio2.c:124: warning: `z' might be used uninitialized in this function
   - may get used at line 199 before getting assigned.  need to be init/set!

   e_sqrt.c:132: warning: `z' might be used uninitialized in this function
   - may get used at line 224 before getting assigned.  need to be init/set!

   k_cos.c:105: warning: `qx' might be used uninitialized in this function
   - same as the above two, hmm ... are these relying on some runtime stack values?
     it seems pretty dangerous not to set/init these, but on the other hand, it
     seems like they are intended.

   *** The use of qx on line 120 in k_cos.c is clearly wrong, as the next two
   *** statements completely overwrite u.d.  This fdlibm code originated from
   *** sun.com, could you please see whether a bug needs to be filed there?
   *** In any case, the JS engine's copy should be fixed to strike line 120.

   *** Same for the e_sqrt.c and e_rem_pio2.c uses.

Who at Sun can follow up with fdlibm authors?  George?

/be

Comment 17

17 years ago
Hi Brendan: I don't know what fdlibm is, but I'd be happy to try to track it
down.  What is it?  Also, can you tell me some of its history?  Maybe I can go
from there and track down the authors.  Or if you even know a Sun name (probably
too much to ask, but I gotta try), I can go from there.

Comment 18

17 years ago
fdlibm is the "freely distributable libm".  It provides software implementations
of the math functions found in libm.  We use fdlibm in the JavaScript engine
when a system-provided math function doesn't conform to the IEEE 754 standard.

I forget exactly where the fdlibm in mozilla CVS came from.  It looks like
version 5.2, which was developed by Sun and released in 1995(!)  fdlibm is
currently distributed as part of netlib, so that might be the right place to
send upstream patches (www.netlib.org).

NetBSD also maintains a copy of fdlibm, based off version 5.1.  They've done
some patches for endian-ness problems, and possibly others.  I'll have a look
(RSN) to see how their current version of our problem files compare.

The readme (from 1995) for fdlibm 5.2 (http://www.netlib.org/fdlibm/readme)
says:
"6. PROBLEMS ?
--------------
Please send comments and bug report to: 
fdlibm-comments@sunpro.eng.sun.com"

Might be worth a shot.

Another tidbit.  The Java 1.2 API spec says that conformant JVMs should have the
same results for math operations as fdlibm:
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Math.html

Updated

17 years ago
Status: NEW → ASSIGNED

Comment 19

16 years ago
- bug 81851 was caused by an uninitialized nsresult.
- bug 84477 "nsCachePrefObserver::Install can return an uninitialized nsresult"
- bug 84498 "xpidl_process_idl may return unitialized value"
- bug 84508 "Tinderbox should compile with -O on Linux to produce
-Wuninitialized warnings."
- attachment 37644 [details] to bug 84508 gives a listing of _243_ uninitialized variables
in an up-to-date build. This means that the number more than doubled since this
bug was filed!
Depends on: 81851, 84477, 84498, 84508

Comment 20

16 years ago
Another good practice is for each engineer to turn warnings all they way up and 
do a build of his or her area. I've often find numerous problems in code by 
doing this in this past. There's plenty of noise, but often there are valid 
warnings that point to bugs.

Comment 21

16 years ago
Created attachment 38857 [details]
Compilation log excerpts showing 247 uninitialized vars; 2001061610 rebuilt from src RPM on RH Linux 7.1

Comment 22

16 years ago
bug 94135 "nsPrefBranch::SetComplexValue : rv may be returned uninitialized"
bug 94141 "modules/libimg/src/if.cpp : IL_StreamWrite return value undefined if
len==0."
Depends on: 94135, 94141

Comment 23

16 years ago
Created attachment 44946 [details]
Compilation log excerpts showing 251 uninitialized vars; 2001080600 rebuilt from src RPM on RH Linux 7.1

Comment 24

16 years ago
bug 94151 "nsBidiPresUtils::FormatUnicodeText can return uninitialized nsresult"
Depends on: 94151

Comment 25

16 years ago
Bug 53593 "uninitialized variables in jsj.c"

I filed a few new NSS bugs:
Bug 95982 "rsa.c: RSA_PrivateKeyOp will return uninitialized SECStatus on success"
Bug 95983 "jarver.c: uninitialized variables might be being used before being set"
Bug 95989 "certdb/genname.c: cert_CompareNameWithConstraints handles certURI
case incorrectly"
Bug 95990 "rijndael.c: encrypt/decrypt use c2 and c3 without ever initializing"

Unfortunatelly, there are much more of these in NSS...
Depends on: 53593, 95982, 95983, 95989, 95990

Comment 26

16 years ago
Created attachment 52326 [details]
2001100515: 278 "may be used uninitialized" warnings

Comment 27

16 years ago
The number of these warnings seems to be finally going down
(http://tinderbox.mozilla.org/SeaMonkey/warn1010614620.16740.html has 269 of
them), but very slowly. It's very likely that some of those 269 are real bugs
and IMHO it would make sence to  try to make sure that do not make it into 1.0
Keywords: mozilla1.0

Comment 28

16 years ago
Created attachment 64250 [details]
267 "may be uninitialized" warnings from todays log

These are the "may be uninitialized" warnings listed in
http://tinderbox.mozilla.org/SeaMonkey/warn1010629440.4199.html
Attachment #19017 - Attachment is obsolete: true
Attachment #19018 - Attachment is obsolete: true
Attachment #38857 - Attachment is obsolete: true
Attachment #44946 - Attachment is obsolete: true
Attachment #52326 - Attachment is obsolete: true

Updated

16 years ago
Depends on: 119220

Updated

16 years ago
Depends on: 5602, 14733, 14737

Updated

16 years ago
Depends on: 119376

Updated

16 years ago
Depends on: 119481

Updated

16 years ago
Depends on: 99324

Comment 29

16 years ago
Created attachment 64819 [details] [diff] [review]
fix for warnings in cookie and wallet code

Comment 30

16 years ago
Comment on attachment 64819 [details] [diff] [review]
fix for warnings in cookie and wallet code

sr=alecf
Attachment #64819 - Flags: superreview+

Comment 31

16 years ago
cookie and wallet fixes are now checked in.  Removing myself from cc list.

Updated

16 years ago
Depends on: 117418

Updated

16 years ago
Depends on: 122904

Comment 32

16 years ago
Created attachment 68209 [details]
190 "may be used uninitialized" warnings from todays log

These are the warnings from
http://tinderbox.mozilla.org/SeaMonkey/warn1013026020.23864.html (Wed, 06 Feb
2002 15:07 EST). The NSS3.4 ladning got rid of a huge number of warnings, so
now we only have 190 of them left!
Attachment #64250 - Attachment is obsolete: true

Updated

16 years ago
Depends on: 124618

Updated

16 years ago
Depends on: 124619

Updated

16 years ago
Depends on: 119330

Updated

16 years ago
Depends on: 124614

Updated

16 years ago
Depends on: 125795

Updated

16 years ago
Depends on: 126457

Updated

16 years ago
Depends on: 126460

Updated

16 years ago
Depends on: 126462

Updated

16 years ago
Depends on: 126463

Updated

16 years ago
Depends on: 126473

Updated

16 years ago
Depends on: 126475

Updated

16 years ago
Depends on: 126484

Updated

16 years ago
Depends on: 126485

Updated

16 years ago
Depends on: 126488

Comment 33

16 years ago
Created attachment 70722 [details]
176 "xxx might be used uninitialized" from today's log.

Distribution by toplevel directory:

46	layout
34	js
16	nsprpub
13	mailnews
10	security
10	extensions
10	content
8	xpfe
6	widget
5	xpinstall
4	xpcom
4	modules
2	string
2	gfx
2	db
1	uriloader
1	rdf
1	intl
1	embedding
Attachment #68209 - Attachment is obsolete: true

Updated

16 years ago
Depends on: 127489

Updated

16 years ago
Depends on: 127490

Updated

16 years ago
Depends on: 127592

Updated

16 years ago
Depends on: 127419

Updated

16 years ago
Depends on: 131347

Updated

16 years ago
Depends on: 132141

Updated

16 years ago
Depends on: 132145

Updated

16 years ago
Depends on: 132148

Updated

16 years ago
Depends on: 132161

Updated

16 years ago
Depends on: 132163

Comment 34

16 years ago
Created attachment 75073 [details]
150 "xxx might be used uninitialized" from today's log.

26 down, 150 to go...
Attachment #70722 - Attachment is obsolete: true

Updated

16 years ago
Depends on: 134556

Updated

16 years ago
Depends on: 136878

Updated

16 years ago
Depends on: 141552

Updated

16 years ago
Depends on: 127289

Updated

16 years ago
Depends on: 145029

Updated

16 years ago
Depends on: 145031

Updated

16 years ago
Depends on: 145947

Updated

15 years ago
Depends on: 152700

Updated

15 years ago
Depends on: 161417

Updated

15 years ago
Depends on: 155652

Updated

15 years ago
Depends on: 165908
Blocks: 179819

Comment 35

15 years ago
Created attachment 109364 [details]
146 warnings from today's brad Tbox log.

Distribution of the lines with warnings, by toplevel dir:

     31 layout
     28 js
     14 content
     13 nsprpub
     11 directory
      4 xpcom
      4 widget
      4 modules
      3 security
      3 mailnews
      3 gfx
      2 tools
      2 string
      2 extensions
      1 xpfe
      1 rdf
      1 profile
      1 intl
Attachment #75073 - Attachment is obsolete: true

Updated

15 years ago
Depends on: 155539

Updated

15 years ago
Blocks: 187528

Updated

15 years ago
Depends on: 188124

Updated

15 years ago
Depends on: 188640

Updated

15 years ago
Depends on: 189563

Updated

15 years ago
Depends on: 191717

Updated

15 years ago
Depends on: 191712

Updated

15 years ago
Depends on: 202594

Updated

14 years ago
Depends on: 208868

Updated

14 years ago
Depends on: 209335

Updated

14 years ago
No longer depends on: 134556

Updated

14 years ago
Depends on: 223702
No longer depends on: 131347
No longer depends on: 188124
No longer depends on: 127489
No longer depends on: 126475
No longer depends on: 132145
No longer depends on: 155539
Depends on: 230397
No longer depends on: 202594
Depends on: 230001
No longer depends on: 230397
No longer depends on: 208868
*** Bug 132145 has been marked as a duplicate of this bug. ***
No longer depends on: 132141
*** Bug 132141 has been marked as a duplicate of this bug. ***
(Assignee)

Comment 38

6 years ago
All the dependent bugs has been closed.

Hence closing the meta bug as well.
Assignee: chofmann → atulagrwl
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.