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)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: gkw, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — — 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)
So the patch makes use assert in debug build and then crash (if mTimer is null). Is that the intention?
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! :)
Assignee: nobody → nth10sd
Status: NEW → ASSIGNED
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-
(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.
Attached patch v2 — — Splinter Review
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+
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 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-
Attachment #374308 - Attachment is obsolete: true
(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.
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.
WONTFIX then. Reopen if otherwise.
Assignee: nth10sd → nobody
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: