Closed Bug 54307 Opened 25 years ago Closed 25 years ago

jsdtoa.c - InitDtoa does not destroy locks

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: jonsmirl, Assigned: mike+mozilla)

Details

Attachments

(6 files)

These two locks are created but never destroyed. #ifdef JS_THREADSAFE static JSBool initialized = JS_FALSE; /* hacked replica of nspr _PR_InitDtoa */ static void InitDtoa(void) { freelist_lock = PR_NewLock(); p5s_lock = PR_NewLock(); initialized = JS_TRUE; } #endif Following patch adds static function TermDtoa() to jsdtoa.c. js_CleanupLocks is modified to call TermDtoa and cleanup jsdtoa.
patch is not quite right. It needs to test to make sure the static have been initialized. void TermDtoa(void) { if (initialized == JS_TRUE) { PR_DestroyLock(freelist_lock); PR_DestroyLock(p5s_lock); } initialized = JS_FALSE; }
cc'ing Brendan and mccabe
The patch looks ok, but could you please prefix TermDtoa with js_ to avoid polluting the global C/C++ namespace? Thanks. /be
Status: UNCONFIRMED → NEW
Ever confirmed: true
Jon, the extern js_TermDtoa(void); prototype is missing a void return type after the extern keyword. Fix that, an a=brendan@mozilla.org (mccabe or rogerl can r= and check into the trunk). /be
Maybe it's just me, but js_TermDtoa seems like an ambiguous name. js_FinishDtoa? Also, I wonder if it makes sense to put the extern declaration in jsdtoa.h. It's part of the API requirement now... The PR_DestroyLock calls in js_TermDtoa should be within a #ifdef JS_THREADSAFE, as they refer to locks that are only defined for JS_THREADSAFE builds. I'd leave the rest of js_TermDtoa outside of JS_THREADSAFE, (even though it doesn't do much) so that the API stays the same, threadsafe or no.
Assignee: rogerl → mccabe
mccabe: good point about js_Finish vs. js_Term -- I promulgated the Init : Finish :: New : Destroy long ago in SpiderMonkey's naming conventions, how could I forget? I think I dimly recalled a Term vs. Init antonym and thought maybe that meme was in jsdtoa.c (code not original to SpiderMonkey), but I should've checked. Also, jsdtoa.h hosting the extern sounds fine. Sometimes, with one-off externs it pays to put the extern in the "importing" .c file and avoid over-including the .h file. If jslock.c doesn't really need anything else from jsdtoa.h (as I believe is the case), then I'm ok with a "one-off extern in the importer" here. /be
Ok, I can a=brendan@mozilla.org that last patch, without conditions. Thanks Jon. mccabe, you ok with the one-off extern? /be
Fix checked in.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Marking Verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: