Closed Bug 1515551 Opened 11 months ago Closed 8 months ago

add functionality to SharedMemoryBasic to help map the shared memory at an arbitrary address

Categories

(Core :: IPC, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: heycam, Assigned: heycam)

Details

Attachments

(1 file)

This is from my WIP patch queue in bug 1474793.

For context, I'm using it like this:

https://hg.mozilla.org/try/file/035babd944215f1973fe957d09ab55783cd908a5/layout/style/nsLayoutStylesheetCache.cpp#l245

i.e. I probe to find a free section of address space that is a fair way away from the current allocations (but not too large, on 32 bit, to avoid eating up too much contiguous free space).  Given ASLR and not being in full control of what other allocations have already happened in the content process by the time I want to map the shared memory, this works reasonably well in practice.  I have not encountered the parent process failing to map at the computed desired address.  On 64 bit, I found the content process always successfully maps at the required address.  On 32 bit, it fails about 1 time in 10.  (On failure we fall back to allocating our own copy of the UA sheets, so it's no big deal.)

Happy to hear better suggestions on how to achieve this, too.
This patch adds two things:

1. An optional fixed_address argument to SharedMemoryBasic::Map, which
   is the address to map the shared memory at.

2. A FindFreeAddressSpace function that callers can use to find a
   contiguous block of free address space, which can then be used to
   determine an address to pass in to Map that is likely to be free.

Patches in bug 1474793 will use these to place the User Agent style
sheets in a shared memory buffer in the parent process at an address
that is also likely to be free in content processes.
Priority: -- → P1
Attachment #9032612 - Attachment description: Bug 1515551 - Add functionality to SharedMemoryBasic to help map the shared memory at an arbitrary address → Bug 1515551 - Add functionality to SharedMemoryBasic to help map the shared memory at an arbitrary address.
Pushed by cmccormack@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a633f5814c0a
Add functionality to SharedMemoryBasic to help map the shared memory at an arbitrary address. r=kmag
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.