Closed Bug 727202 Opened 8 years ago Closed 8 years ago

GeckoAppShell.allocateDirectBuffer and freeDirectBuffer don't use jemalloc to allocate/free buffers

Categories

(Core :: mozglue, defect)

ARM
Android
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: blassey, Assigned: glandium)

Details

Attachments

(1 file)

I noticed this issue when working on bug 726930 because my code malloc'd the buffer directly then called GeckoAppShell.freeDirectBuffer() to free it and that crashed because of the mismatched allocator.
Assignee: nobody → jdhaliwal
Assignee: jdhaliwal → nobody
Component: General → mozglue
Product: Fennec Native → Core
QA Contact: general → mozglue
Summary: GeckoAppShell.allocateDirectBuffer doesn't use jemalloc to allocate its buffer → mozglue internally doesn't use jemalloc
OS: Mac OS X → Android
Hardware: x86 → ARM
Assignee: nobody → mh+mozilla
Sadly, generalization can't be done in mozglue, because some things that we free() are allocated by the android libc. So in the end, this will need to be a localized fix.
Summary: mozglue internally doesn't use jemalloc → GeckoAppShell.allocateDirectBuffer and freeDirectBuffer don't use jemalloc to allocate/free buffers
Attachment #597412 - Flags: review?(blassey.bugs) → review+
Comment on attachment 597412 [details] [diff] [review]
Wrap malloc and free to use jemalloc in GeckoAppShell.{allocate,free}DirectBuffer

Mike, I think I'd slightly prefer using the --wrap flags so nothing else allocates using the standard allocators. Is there any reason not to do that?
One reason is that --wrap only works when the wrapped function is in an external library. mozglue/android and jemalloc are in the same library.
The other reason is in comment 1.
(In reply to Mike Hommey [:glandium] from comment #4)
> One reason is that --wrap only works when the wrapped function is in an
> external library. mozglue/android and jemalloc are in the same library.
> The other reason is in comment 1.

Right, I failed to read comment 1 before commenting. So, ignore comment 3.
Not that eventually, mozalloc will be folded in mozglue, at which point using operator new and delete in mozglue will use jemalloc. When that happens, we can remove this hack and replace malloc and free with new and delete.
(In reply to Mike Hommey [:glandium] from comment #6)
> Not that eventually,(...)

Note, not not
https://hg.mozilla.org/mozilla-central/rev/7e90fe61000f
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.