Closed Bug 164294 Opened 23 years ago Closed 23 years ago

NTBUCKETS returns 1 for an empty hash table

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mkaply, Assigned: dougt)

Details

Attachments

(1 file)

See http://lxr.mozilla.org/seamonkey/source/nsprpub/lib/ds/plhash.c#425 If you call an enumerate function on an empty hash table, it crashes. It shouldn't. The problem is that the NTBUCKETS macro is returning 1 even though the hash table is empty.
Michael, I don't understand this bug. As this test program demonstrates, I can enumerate an empty hash table without crashing. The PL_HashTableEnumerateEntries correctly returns 0.
Interesting. Maybe the problem is only with a hash table created with nsHashTable (XPCOM) I create an nsHashTable hashtable; and if I try to enumerate on it, I crash. I'll move this to XPCOM.
Assignee: wtc → dougt
Component: NSPR → XPCOM
Product: NSPR → Browser
QA Contact: wtc → scc
Version: 4.3 → other
Mike, do you have a test case which demonstrates this crash you are seeing?
Not exactly. I'll create one. We found it when creating a hashtable for our font code. We put an nsHashTable in a class (not a pointer) then we added code at shutdown that enumerated the hashtable and freed the entries. What we found is that if we had not added anything, the ::enumerate still called into NSPR.
My bad. A static initializer wasn't getting called because we wrote our own DLL init function. This was masquerading as this problem. nsHashTables always have 16 by default - it's in the default constructor.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: