Closed
Bug 489847
Opened 17 years ago
Closed 17 years ago
Add a NS_ASSERTION for mTimer just-in-case
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: gkw, Unassigned)
Details
Attachments
(1 file, 1 obsolete file)
|
758 bytes,
patch
|
bent.mozilla
:
review+
smaug
:
superreview-
|
Details | Diff | Splinter Review |
http://mxr.mozilla.org/comm-central/source/mozilla/dom/src/threads/nsDOMWorkerTimeout.cpp#394
has a mTimer->Cancel(); call without a NS_ASSERTION(mTimer, "Impossible to get here without a timer!");
This can crash if mTimer is ever null in Suspend(), not that likely but just-in-case.
Attachment #374308 -
Flags: review?(bent.mozilla)
Comment 1•17 years ago
|
||
So the patch makes use assert in debug build and then crash (if mTimer is null). Is that the intention?
Comment 2•17 years ago
|
||
s/use/us/
| Reporter | ||
Comment 3•17 years ago
|
||
mTimer->Cancel(); calls in other parts of the Mozilla codebase use an "if (mTimer)" block to ensure it's never null. I was following the coding convention in the whole nsDOMWorkerTimeout.cpp file which adds the NS_ASSERTION but doesn't have the "if (mTimer)" block.
Should I then add the "if (mTimer)" block for the other uses of mTimer->Cancel(); in this file? (I think there's some other uses, in Cancel() amongst others)
Forgive my not-so-good C++-isms, it's my first C++ patch! :)
| Reporter | ||
Updated•17 years ago
|
Assignee: nobody → nth10sd
Status: NEW → ASSIGNED
Comment 4•17 years ago
|
||
I'm just saying that NS_ASSERTION doesn't prevent anything happening,
it just prints out something in debug builds.
Comment on attachment 374308 [details] [diff] [review]
patch
This patch is incorrect in any case. You'd want it after the !mStarted early return.
Attachment #374308 -
Flags: review?(bent.mozilla) → review-
| Reporter | ||
Comment 6•17 years ago
|
||
(In reply to comment #5)
> (From update of attachment 374308 [details] [diff] [review])
> This patch is incorrect in any case. You'd want it after the !mStarted early
> return.
Do you want "if (mTimer)" block checks for each mTimer->Cancel(); function? If so, I'll whip up something tomorrow, it's 3am local time...
No, everything should stay the way it is. If you want to add an assertion (and I agree with smaug that it doesn't really help much) then you'd have to add it just before mTimer->Cancel.
| Reporter | ||
Comment 8•17 years ago
|
||
Attachment #374319 -
Flags: superreview?(Olli.Pettay)
Attachment #374319 -
Flags: review?(bent.mozilla)
Comment on attachment 374319 [details] [diff] [review]
v2
Should be fine.
Attachment #374319 -
Flags: review?(bent.mozilla) → review+
Comment 10•17 years ago
|
||
i don't see the point. if you have a debugger, you'll end up in the same place either way.
worse, mTimer is an nsCOMPtr<> which means -> will assert for you, which makes this pointless.
If you don't want to crash in a release build then you can't use an assertion.
if you don't want to crash in a debugger, you can just walk past it. It's painful, sure, but, i can do it :).
The only thing that this would buy us is a more helpful log message on test boxes (assuming we have ones with debug messages enabled).
Comment 12•17 years ago
|
||
Comment on attachment 374319 [details] [diff] [review]
v2
Sorry, but I see no reason for this. As timeless mentioned, we get anyway an assertion if mTimer is null.
Attachment #374319 -
Flags: superreview?(Olli.Pettay) → superreview-
| Reporter | ||
Updated•17 years ago
|
Attachment #374308 -
Attachment is obsolete: true
| Reporter | ||
Comment 13•17 years ago
|
||
(In reply to comment #12)
> (From update of attachment 374319 [details] [diff] [review])
> Sorry, but I see no reason for this. As timeless mentioned, we get anyway an
> assertion if mTimer is null.
I was thinking there might be a possibility of something going wrong if mTimer is null, e.g. in bug 489779 (null mTimer crash), but maybe I'm wrong and this bug should be WONTFIX.
Comment 14•17 years ago
|
||
Something is wrong if mTimer is null. And if that is the case,
nsCOMPtr will assert about using null, and the program will crash.
Adding an NS_ASSERTION doesn't change anything there.
| Reporter | ||
Comment 15•17 years ago
|
||
WONTFIX then. Reopen if otherwise.
Assignee: nth10sd → nobody
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•