Closed Bug 1574390 Opened 5 years ago Closed 5 years ago

Implement guard pages in PHC

Categories

(Core :: Memory Allocator, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: n.nethercote, Assigned: n.nethercote)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 6 obsolete files)

We can put a guard page next to each allocation page and possibly catch bounds violations. It costs additional virtual memory, but no physical memory, and PHC is only enabled on 64-bit platforms which have plenty of virtual memory.

Attached file Bug 1574390 - [DRAFT] Implement guard pages in PHC. (obsolete) (deleted) —

XX: the patch adds the guard pages, and things appear to work fine. However,
it has not yet moved allocations so they abut the guard pages, so it's unlikely
to be useful yet for anything other than page-sized allocations.

Depends on D42267

Attachment #9085975 - Attachment is obsolete: true

This reduces the indentation level by one for most of the loop body.

Depends on D42267

Attached file Bug 1574390 - Improve some PHC comments. r=glandium (obsolete) (deleted) —

Depends on D43837

It probably doesn't matter, but we might as well copy enough bytes to
completely fill up the usable space of the new allocation when possible.

Depends on D43838

Currently the PHC code uses char* and uintptr_t in various address
computations. This patch changes it to use uint8_t* instead, which is clearer
than char* and avoids the need for various casts.

Depends on D43839

This is in preparation for the introduction of "guard pages", which are
interleaved with alloc pages. The specific renamings are:

  • kMaxPageAllocs --> kNumAllocPages
  • PagePtr --> AllocPagePtr
  • PageState --> AllocPageState
  • PageInfo --> AllocPageInfo
  • mPages --> mAllocPages
  • AssertPageInUse --> AssertAllocPageInUse

Depends on D43840

Each allocation page is now followed by a guard page, and allocations are put
at the end of their page so that bounds violations trigger a crash.

Various operations (realloc(), free(), malloc_usable_size()) now require that
the pointer they are given points to the start of an allocation.

Depends on D43841

Comment on attachment 9085973 [details]
Bug 1574390 - Fix some broken PHC_LOGGING code. r=glandium

Revision D42267 was moved to bug 1594598. Setting attachment 9085973 [details] to obsolete.

Attachment #9085973 - Attachment is obsolete: true

Comment on attachment 9088871 [details]
Bug 1574390 - Tweak the control flow in MaybePageAlloc()'s loop. r=glandium

Revision D43837 was moved to bug 1594598. Setting attachment 9088871 [details] to obsolete.

Attachment #9088871 - Attachment is obsolete: true

Comment on attachment 9088872 [details]
Bug 1574390 - Improve some PHC comments. r=glandium

Revision D43838 was moved to bug 1594598. Setting attachment 9088872 [details] to obsolete.

Attachment #9088872 - Attachment is obsolete: true

Comment on attachment 9088874 [details]
Bug 1574390 - Use uint8_t* to avoid a bunch of casts. r=glandium

Revision D43840 was moved to bug 1594598. Setting attachment 9088874 [details] to obsolete.

Attachment #9088874 - Attachment is obsolete: true
Attachment #9088873 - Attachment is obsolete: true
Pushed by nnethercote@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8e14578c59d7 Change terminology from "pages" to "alloc pages". r=glandium
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
Regressions: 1625378
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: