Closed
Bug 642539
Opened 15 years ago
Closed 15 years ago
mmfx_new_array_opt(type, n, opts) does not honor MMgc::kCanFail
Categories
(Tamarin Graveyard :: Garbage Collection (mmGC), defect)
Tamarin Graveyard
Garbage Collection (mmGC)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: brbaker, Assigned: pnkfelix)
References
Details
(Whiteboard: WE:2833668)
Attachments
(2 files)
|
883 bytes,
patch
|
lhansen
:
review+
|
Details | Diff | Splinter Review |
|
25.40 KB,
patch
|
pnkfelix
:
review+
dschaffe
:
review+
|
Details | Diff | Splinter Review |
mmfx_new_array_opt(type, n, opts) will not return NULL when it is unable to allocate the requested array if MMgc::kCanFail is passed as an option.
It appears that the issue here is that when MMGC_OVERRIDE_GLOBAL_NEW is NOT defined, the mmfx_new_array_opt macro is MMgcConstructTaggedArray((type*)NULL, n, opts), which calls MMgc::NewTaggedArray() which then calls GCHeap::CheckForCallocSizeOverflow() which does not take into account the passed in FixedMallocOpts, and if GCHeap::CheckForCallocSizeOverflow() fails to allocate it aborts.
Selftest snippet:
%%test mmfx_new_array_opts_canFail
// This should fail and return NULL
int* m_ints = mmfx_new_array_opt(int, sizeof(int)*2147483647, MMgc::kCanFail);
%%verify m_ints == NULL
mmfx_delete_array(m_ints);
m_ints = NULL;
Flags: in-testsuite?
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Flags: flashplayer-injection-
Flags: flashplayer-bug+
Comment 1•15 years ago
|
||
That may be by design. Unless I remember wrong, allocation size overflow has always been defined as a fatal error condition, regardless of kCanFail. There was a meeting in 601T about a year ago where we tossed around the utility (or lack thereof) of the MemoryError that the Player sometimes throws for too-large allocation requests, and after some investigation decided - Lee was present - that it was pretty much meaningless to try to keep that alive - it was incorrectly implemented, many crashers, etc in older players, nothing anyone could rely on.
I believe that GC::Alloc and GC::Calloc similarly just abort on too-large requests.
I hope the above snippet was from a 64-bit build, it scarcely makes sense in a 32-bit setting with that multiplication. Actually, should the multiplication even be there? I don't think so.
| Assignee | ||
Comment 2•15 years ago
|
||
(In reply to comment #1)
> That may be by design. Unless I remember wrong, allocation size overflow has
> always been defined as a fatal error condition, regardless of kCanFail.
Brents original point, namely that the following is a bug:
> mmfx_new_array_opt(type, n, opts) will not return NULL when it is unable to
> allocate the requested array if MMgc::kCanFail is passed as an option.
still holds, regardless of how we handle allocation size overflow.
See e.g. Bug 645646, comment 8.
| Assignee | ||
Updated•15 years ago
|
Assignee: nobody → fklockii
| Assignee | ||
Comment 3•15 years ago
|
||
Lars: this is blocking Bug 645646, which I'd like to land in Wasabi if possible.
In any case this patch strikes me as an improvement (unless our compilers don't do a good job of optimizing away the conditional).
Attachment #523511 -
Flags: review?(lhansen)
Comment 4•15 years ago
|
||
Comment on attachment 523511 [details] [diff] [review]
bomb out early with null w/o running ctors for elems
For this function it's unlikely that adding a check will perturb performance at all; last I checked our compilers did not get rid of the initialization loop even if the element constructor is trivial.
Attachment #523511 -
Flags: review?(lhansen) → review+
Comment 5•15 years ago
|
||
changeset: 6152:c47c5c49382d
user: Felix S Klock II <fklockii>
summary: Bug 642539: allow mmfx_new_array_opt to kFail (r=lhansen).
http://hg.mozilla.org/tamarin-redux/rev/c47c5c49382d
| Assignee | ||
Updated•15 years ago
|
Whiteboard: WE:2833668
| Assignee | ||
Comment 6•15 years ago
|
||
Pushed to Wasabi as part of the p4 CL 878813
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 7•15 years ago
|
||
Add selftests for mmfx_new_array() and mmfx_new_array_opts() OOM condition and also mmfx_new_array_opts(kCanFail).
Selftests are explicit since they must be run with -memlimit and the OOM tests are expected to shutdown the shell with an exitcode of 128.
Felix: You can ignore the testSelftest.py change, I will request a review from dschaffe for that part,
Attachment #524061 -
Flags: review?(fklockii)
| Reporter | ||
Comment 8•15 years ago
|
||
Comment on attachment 524061 [details] [diff] [review]
selftest testcase
Dan could you review the cmdline/testSelftest.py change.
Attachment #524061 -
Flags: review?(dschaffe)
| Assignee | ||
Updated•15 years ago
|
Attachment #524061 -
Flags: review?(fklockii) → review+
Comment 9•15 years ago
|
||
Comment on attachment 524061 [details] [diff] [review]
selftest testcase
test/cmdline/testSelfTest.py ran correctly on mac and the test/cmdline/runtests.py ran testSelfTest.py correctly. patch looks good.
Attachment #524061 -
Flags: review?(dschaffe) → review+
Comment 10•15 years ago
|
||
changeset: 6178:7f564f473053
user: Brent Baker <brbaker@adobe.com>
summary: Bug 642539: selftest for mmfx_new_array*() (r=fklockii,r=dscahffe)
http://hg.mozilla.org/tamarin-redux/rev/7f564f473053
| Reporter | ||
Updated•15 years ago
|
Status: RESOLVED → VERIFIED
Flags: in-testsuite? → in-testsuite+
Updated•15 years ago
|
Flags: flashplayer-qrb? → flashplayer-qrb+
You need to log in
before you can comment on or make changes to this bug.
Description
•