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

RESOLVED FIXED in mozilla13

Status

()

Core
mozglue
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: blassey, Assigned: glandium)

Tracking

unspecified
mozilla13
ARM
Android
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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)

Updated

6 years ago
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
(Assignee)

Updated

6 years ago
OS: Mac OS X → Android
Hardware: x86 → ARM
(Assignee)

Updated

6 years ago
Assignee: nobody → mh+mozilla
(Assignee)

Comment 1

6 years ago
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
(Assignee)

Comment 2

6 years ago
Created attachment 597412 [details] [diff] [review]
Wrap malloc and free to use jemalloc in GeckoAppShell.{allocate,free}DirectBuffer
Attachment #597412 - Flags: review?(blassey.bugs)
(Reporter)

Updated

6 years ago
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?
(Assignee)

Comment 4

6 years ago
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.
(Assignee)

Comment 6

6 years ago
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.
(Assignee)

Comment 7

6 years ago
(In reply to Mike Hommey [:glandium] from comment #6)
> Not that eventually,(...)

Note, not not
(Assignee)

Comment 8

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/7e90fe61000f

Comment 9

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