NTBUCKETS returns 1 for an empty hash table

RESOLVED INVALID

Status

()

RESOLVED INVALID
17 years ago
16 years ago

People

(Reporter: mkaply, Assigned: dougt)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
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.

Comment 1

17 years ago
Created attachment 96477 [details]
A test program that enumerates an empty hash table

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.
(Reporter)

Comment 2

17 years ago
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
(Assignee)

Comment 3

16 years ago
Mike, do you have a test case which demonstrates this crash you are seeing?
(Reporter)

Comment 4

16 years ago
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.

(Reporter)

Comment 5

16 years ago
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
Last Resolved: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.