Bug 1464789 - If page-size is not 4K, the function of LazyStubTier::createMany would trigger a segment fault within executableCopy. r=luke
authorqiaopengcheng <qiaopengcheng-hf@loongson.cn>
Mon, 28 May 2018 18:16:00 +0300
changeset 420504 fc4c476186abb850d78a393eca9996d6ca7f6c83
parent 420503 8398d902299c9df8c0cb522d2d34c1419ee2682b
child 420505 3a2d42c1c0d47e11a1efc666cce491f3064469ef
push id34073
push useraiakab@mozilla.com
push dateWed, 30 May 2018 22:05:51 +0000
treeherdermozilla-central@3931f461c8e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1464789
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464789 - If page-size is not 4K, the function of LazyStubTier::createMany would trigger a segment fault within executableCopy. r=luke
js/src/wasm/WasmCode.cpp
js/src/wasm/WasmCode.h
--- a/js/src/wasm/WasmCode.cpp
+++ b/js/src/wasm/WasmCode.cpp
@@ -551,17 +551,17 @@ LazyStubSegment::create(const CodeTier& 
         return nullptr;
 
     return segment;
 }
 
 bool
 LazyStubSegment::hasSpace(size_t bytes) const
 {
-    MOZ_ASSERT(bytes % MPROTECT_PAGE_SIZE == 0);
+    MOZ_ASSERT(AlignBytesNeeded(bytes) == bytes);
     return bytes <= length() &&
            usedBytes_ <= length() - bytes;
 }
 
 bool
 LazyStubSegment::addStubs(size_t codeLength, const Uint32Vector& funcExportIndices,
                           const FuncExportVector& funcExports, const CodeRangeVector& codeRanges,
                           uint8_t** codePtr, size_t* indexFirstInsertedCodeRange)
--- a/js/src/wasm/WasmCode.h
+++ b/js/src/wasm/WasmCode.h
@@ -502,27 +502,25 @@ using UniqueMetadataTier = UniquePtr<Met
 using UniqueLazyStubSegment = UniquePtr<LazyStubSegment>;
 using LazyStubSegmentVector = Vector<UniqueLazyStubSegment, 0, SystemAllocPolicy>;
 
 class LazyStubSegment : public CodeSegment
 {
     CodeRangeVector codeRanges_;
     size_t usedBytes_;
 
-    static constexpr size_t MPROTECT_PAGE_SIZE = 4 * 1024;
-
   public:
     LazyStubSegment(UniqueCodeBytes bytes, size_t length)
       : CodeSegment(Move(bytes), length, CodeSegment::Kind::LazyStubs),
         usedBytes_(0)
     {}
 
     static UniqueLazyStubSegment create(const CodeTier& codeTier, size_t codeLength);
 
-    static size_t AlignBytesNeeded(size_t bytes) { return AlignBytes(bytes, MPROTECT_PAGE_SIZE); }
+    static size_t AlignBytesNeeded(size_t bytes) { return AlignBytes(bytes, gc::SystemPageSize()); }
 
     bool hasSpace(size_t bytes) const;
     bool addStubs(size_t codeLength, const Uint32Vector& funcExportIndices,
                   const FuncExportVector& funcExports, const CodeRangeVector& codeRanges,
                   uint8_t** codePtr, size_t* indexFirstInsertedCodeRange);
 
     const CodeRangeVector& codeRanges() const { return codeRanges_; }
     const CodeRange* lookupRange(const void* pc) const;