Closed Bug 256615 Opened 21 years ago Closed 21 years ago

crash when calling nsIThread.state before calling nsIThread.init [@ PR_GetThreadState]

Categories

(Core :: XPCOM, defect)

x86
Windows XP
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Assigned: csthomas)

Details

(Keywords: crash)

Crash Data

Attachments

(1 file, 1 obsolete file)

steps: run xpcshell execute: Components.classes["@mozilla.org/thread;1"].createInstance(Components.interfaces.nsIThread).state; actual results: nspr4.dll!PR_GetThreadState(const PRThread * thread=0x00000000) Line 445 + 0x4 C > xpcom.dll!nsThread::GetState(PRThreadState * result=0x0012e7c0) Line 232 + 0x9 C++ xpcom.dll!XPTC_InvokeByIndex(nsISupports * that=0x0012e944, unsigned int methodIndex=0x00fb219c, unsigned int paramCount=0x0185b008, nsXPTCVariant * params=0x00000008) Line 102 C++ expected results: exception (NS_ERROR_NOT_INITIALIZED)
hmm, lets either protect all of the methods that access mThread or add comments to the idl that suggest calling into any other method without a successful call to init is undefined.
<CTho> dougt: so we should add an assert then, too, since those functions shoudln't be called, right? <dougt> that would be nice too. let developers (using debug builds) know that there is a problem. I'll go through and edit all of the functions that currently break if mThread is null.
Status: NEW → ASSIGNED
ctho: fwiw a PR_ASSERT is fatal, it will intentionally terminate the app if it fails.
So do I add a null check and no assert and early return, a null check and a non-fatal assert and early return, or a fatal assert?
Attached patch patch v2Splinter Review
Null check, early return, no asserts.
Attachment #156820 - Attachment is obsolete: true
Comment on attachment 157019 [details] [diff] [review] patch v2 looks great. thanks for the fix.
Attachment #157019 - Flags: review?(dougt) → review+
mozilla/xpcom/threads/nsThread.cpp 1.56
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Crash Signature: [@ PR_GetThreadState]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: