Closed
Bug 464043
Opened 16 years ago
Closed 15 years ago
change nsDeque to use malloc for mData
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a1
People
(Reporter: timeless, Assigned: timeless)
References
Details
Attachments
(1 file, 1 obsolete file)
895 bytes,
patch
|
benjamin
:
review+
beltzner
:
approval1.9.2.2+
beltzner
:
approval1.9.1.9+
|
Details | Diff | Splinter Review |
bug 457483 comment 26 shows nsDeque fails under low memory.
I have other patches which would change Push(Front) to indicate failure to the callers. I'm working on it in a repo, I'd want to test that before I pushed it to a bug, but this is actually independent
Attachment #347291 -
Flags: review?(Olli.Pettay)
Comment 1•16 years ago
|
||
Comment on attachment 347291 [details] [diff] [review]
stage one - don't crash
>- void** temp=new void*[theNewSize];
>+ void** temp=(void**)malloc(theNewSize * sizeof(void*));
This should use C++ casting, not C.
>+ PRInt32 capacity = mCapacity;
>+ if (GrowCapacity() == capacity) {
>+ NS_WARNING("No memory for element");
>+ return *this;
>+ }
>+ PRInt32 capacity = mCapacity;
>+ if (GrowCapacity() == capacity) {
>+ NS_WARNING("No memory for element");
>+ return *this;
>+ }
These are kind of useless if the caller doesn't know that the call has failed.
How is the other patch?
Comment 2•16 years ago
|
||
Comment on attachment 347291 [details] [diff] [review]
stage one - don't crash
Waiting to get some answer to the question - clearing the review request for now.
Attachment #347291 -
Flags: review?(Olli.Pettay)
smaug: waiting for answers to questions fails. dbaron did some stuff in bug 520661
smaug: please note that dbaron took in the warning bits that you complained about.
all that's left is the don't throw c++ exceptions bit. I have a real live customer who complained about that in bug 526843.
Attachment #347291 -
Attachment is obsolete: true
Attachment #411698 -
Flags: review?(Olli.Pettay)
Comment 5•15 years ago
|
||
Comment on attachment 411698 [details] [diff] [review]
just the malloc changes
Benjamin is an XPCOM peer.
Attachment #411698 -
Flags: review?(Olli.Pettay) → review?(benjamin)
Comment 6•15 years ago
|
||
...but the patch looks ok to me :)
Updated•15 years ago
|
Attachment #411698 -
Flags: review?(benjamin) → review+
Updated•15 years ago
|
Keywords: checkin-needed
Comment 7•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
Attachment #411698 -
Flags: approval1.9.2.2?
Attachment #411698 -
Flags: approval1.9.1.9?
Comment 9•15 years ago
|
||
Is it really the case that we have to stop using operator new to avoid C++ exceptions, which might nest into JS while the JS GC is running below the code that called new? I don't believe it.
There are lots of operator new uses in our code. nsDeque is hardly first, or last.
/be
(In reply to comment #9)
> Is it really the case that we have to stop using operator new to avoid C++
> exceptions, which might nest into JS while the JS GC is running below the code
> that called new? I don't believe it.
>
No. After abort-on-OOM re-lands this week, std::bad_alloc will be gone forever. (Initially it'll be replaced with abort(), which isn't much better on windows, but that's not the long-term solution.)
Comment 11•15 years ago
|
||
Doesn't using non-throwing new make more sense than malloc(In reply to comment #9)
> Is it really the case that we have to stop using operator new to avoid C++
> exceptions, which might nest into JS while the JS GC is running below the code
> that called new? I don't believe it.
>
> There are lots of operator new uses in our code. nsDeque is hardly first, or
> last.
Just as another idea on this, I guess using non-throwing new is also a possibility?
Comment 12•15 years ago
|
||
(In reply to comment #11)
> Doesn't using non-throwing new make more sense than malloc(In reply to comment
> #9)
> > Is it really the case that we have to stop using operator new to avoid C++
> > exceptions, which might nest into JS while the JS GC is running below the code
> > that called new? I don't believe it.
> >
> > There are lots of operator new uses in our code. nsDeque is hardly first, or
> > last.
> Just as another idea on this, I guess using non-throwing new is also a
> possibility?
See bug 353144 and the brief newsgroup thread it spawned for back-story:
http://groups.google.com/group/mozilla.dev.platform/browse_frm/thread/650c48ab782d296/93fbbef5fc6525b5?lnk=gst&q=353144#93fbbef5fc6525b5
Chris Jones et al. have a better plan for mozilla-central. Timeless argues this particular patch is helpful on branches -- could be, drivers can decide.
What I hope we can avoid is trying to annotate all operator new uses in our codebase. The strong preference of developers is not to have yet another Mozilla-ism on top of standard (for some value of standard) C++.
/be
Comment 13•15 years ago
|
||
Comment on attachment 411698 [details] [diff] [review]
just the malloc changes
a1919/1922=beltzner for this particular case, though I agree with Brendan's comments above.
Attachment #411698 -
Flags: approval1.9.2.2?
Attachment #411698 -
Flags: approval1.9.2.2+
Attachment #411698 -
Flags: approval1.9.1.9?
Attachment #411698 -
Flags: approval1.9.1.9+
Assignee | ||
Comment 14•15 years ago
|
||
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/26d330339592
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/a0da93ff265d
status1.9.1:
--- → .9-fixed
status1.9.2:
--- → .2-fixed
Comment 15•15 years ago
|
||
Is there anything for QA to do here? It doesn't look like it.
You need to log in
before you can comment on or make changes to this bug.
Description
•