|
7 | 7 | # 7. Fix build errors in SIMD IndexOf/includes (https://crrev.com/c/3749192).
|
8 | 8 | # 8. Fix build on arm64.
|
9 | 9 | # 9. Fix build on older versions of Linux.
|
| 10 | +# 10. Fix MemoryAllocator::PartialFreeMemory() which shouldn't try to change permissions of RWX pages, |
| 11 | +# mainly affecting macOS on Apple silicon (https://crrev.com/c/3700352). This can be removed |
| 12 | +# when we adopt 10.5 or higher (https://github.com/envoyproxy/envoy/issues/23258). |
10 | 13 |
|
11 | 14 | diff --git a/BUILD.bazel b/BUILD.bazel
|
12 | 15 | index 13f2a5bebf..2197568c48 100644
|
@@ -363,3 +366,37 @@ index 131ff9614e..6455f8757d 100644
|
363 | 366 | char filename[] = "/tmp/v8_tmp_file_for_testing_XXXXXX";
|
364 | 367 | fd = mkstemp(filename);
|
365 | 368 | if (fd != -1) CHECK_EQ(0, unlink(filename));
|
| 369 | +diff --git a/src/heap/memory-allocator.cc b/src/heap/memory-allocator.cc |
| 370 | +index de143d8ea7..cca4dfe5dd 100644 |
| 371 | +--- a/src/heap/memory-allocator.cc |
| 372 | ++++ b/src/heap/memory-allocator.cc |
| 373 | +@@ -416,8 +416,14 @@ void MemoryAllocator::PartialFreeMemory(BasicMemoryChunk* chunk, |
| 374 | + DCHECK_EQ(0, chunk->area_end() % static_cast<Address>(page_size)); |
| 375 | + DCHECK_EQ(chunk->address() + chunk->size(), |
| 376 | + chunk->area_end() + MemoryChunkLayout::CodePageGuardSize()); |
| 377 | +- reservation->SetPermissions(chunk->area_end(), page_size, |
| 378 | +- PageAllocator::kNoAccess); |
| 379 | ++ |
| 380 | ++ if (V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT && !isolate_->jitless()) { |
| 381 | ++ DCHECK(isolate_->RequiresCodeRange()); |
| 382 | ++ reservation->DiscardSystemPages(chunk->area_end(), page_size); |
| 383 | ++ } else { |
| 384 | ++ reservation->SetPermissions(chunk->area_end(), page_size, |
| 385 | ++ PageAllocator::kNoAccess); |
| 386 | ++ } |
| 387 | + } |
| 388 | + // On e.g. Windows, a reservation may be larger than a page and releasing |
| 389 | + // partially starting at |start_free| will also release the potentially |
| 390 | +@@ -686,10 +692,10 @@ bool MemoryAllocator::SetPermissionsOnExecutableMemoryChunk(VirtualMemory* vm, |
| 391 | + const Address code_area = start + code_area_offset; |
| 392 | + const Address post_guard_page = start + chunk_size - guard_size; |
| 393 | + |
| 394 | +- bool jitless = unmapper_.heap_->isolate()->jitless(); |
| 395 | ++ bool jitless = isolate_->jitless(); |
| 396 | + |
| 397 | + if (V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT && !jitless) { |
| 398 | +- DCHECK(unmapper_.heap_->isolate()->RequiresCodeRange()); |
| 399 | ++ DCHECK(isolate_->RequiresCodeRange()); |
| 400 | + // Commit the header, from start to pre-code guard page. |
| 401 | + // We have to commit it as executable becase otherwise we'll not be able |
| 402 | + // to change permissions to anything else. |
0 commit comments