Should null protect nsCRT::HashCode()

RESOLVED FIXED

Status

()

Core
XPCOM
P3
major
RESOLVED FIXED
17 years ago
17 years ago

People

(Reporter: Paul Chen, Assigned: dougt)

Tracking

({crash})

Trunk
x86
All
crash
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

17 years ago
The reason we crash in bug 91726 is because we pass a null for the char*
parameter to nsCRT::HashCode(). There are some people who believe that
nsCRT::HashCode() should at least not die when given such input.
(Reporter)

Comment 1

17 years ago
taking this bug
Assignee: kandrot → pchen
(Reporter)

Comment 2

17 years ago
marking p3, minor, and future
Severity: normal → minor
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → Future

Comment 3

17 years ago
Just saw another crash in nsCRT::HashCode - see bug 118492
Severity: minor → normal
(Assignee)

Comment 4

17 years ago
*** Bug 118492 has been marked as a duplicate of this bug. ***
(Assignee)

Comment 5

17 years ago
From dup:

Just saw Mozilla crash in nsCRT::HashCode()

GDB output:
[...]
Program terminated with signal 11, Segmentation fault.
[...]
(gdb) bt
#0  0x40117cb8 in nsCRT::HashCode () from /usr/lib/libxpcom.so
#1  0x4011ab31 in nsCStringKey::HashCode () from /usr/lib/libxpcom.so
#2  0x4011a08f in PL_HashTableFinalize () from /usr/lib/libxpcom.so
#3  0x401c28c6 in PL_HashTableLookup () from /usr/lib/libplds4.so
#4  0x4011a455 in nsHashtable::Get () from /usr/lib/libxpcom.so
#5  0x4011b48b in nsSupportsHashtable::Get () from /usr/lib/libxpcom.so
#6  0x41072f94 in NSGetModule () from /usr/lib/mozilla/components/libjar50.so
#7  0x408365a2 in NSGetModule () from /usr/lib/mozilla/components/libnecko.so
#8  0x40836600 in NSGetModule () from /usr/lib/mozilla/components/libnecko.so
#9  0x407e1256 in NSGetModule () from /usr/lib/mozilla/components/libnecko.so
#10 0x407e1160 in NSGetModule () from /usr/lib/mozilla/components/libnecko.so
#11 0x4015c86b in nsThreadPoolRunnable::Run () from /usr/lib/libxpcom.so
#12 0x4015b32b in nsThread::Main () from /usr/lib/libxpcom.so
#13 0x401ea4e4 in _pt_root () from /usr/lib/libnspr4.so
#14 0x401fac6f in pthread_start_thread (arg=0x434ffbe0) at manager.c:284

Assignee: pchen → dougt
Status: ASSIGNED → NEW
(Assignee)

Updated

17 years ago
Target Milestone: Future → ---

Updated

17 years ago
Severity: normal → major
Keywords: crash
(Assignee)

Comment 6

17 years ago
scc's change removed the check for null in the hashing algorithm.  

http://bonsai.mozilla.org/cvsview2.cgi?diff_mode=context&whitespace_mode=show&root=/cvsroot&subdir=mozilla/xpcom/ds&command=DIFF_FRAMESET&file=nsCRT.cpp&rev2=3.38&rev1=3.37

I do not see the harm in placing it back.
(Assignee)

Comment 7

17 years ago
Created attachment 64695 [details] [diff] [review]
protects against null input.
(Assignee)

Comment 8

17 years ago
Created attachment 64696 [details] [diff] [review]
protects against null input.
(Assignee)

Comment 9

17 years ago
brendan, alecf, can you review this?

Comment 10

17 years ago
Comment on attachment 64696 [details] [diff] [review]
protects against null input.

sure
sr=alecf
Attachment #64696 - Flags: superreview+

Updated

17 years ago
Attachment #64696 - Flags: review+

Comment 11

17 years ago
r=dp
(Assignee)

Comment 12

17 years ago
Thanks reviewers.


Checking in nsCRT.cpp;
/cvsroot/mozilla/xpcom/ds/nsCRT.cpp,v  <--  nsCRT.cpp
new revision: 3.49; previous revision: 3.48
done
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.