Commit 8d24472a authored by ulan's avatar ulan Committed by Commit bot

Check for semaphore alignment on posix platforms.

BUG=chromium:605349
LOG=NO

Review URL: https://codereview.chromium.org/1912923003

Cr-Commit-Position: refs/heads/master@{#35717}
parent b0907152
......@@ -74,6 +74,13 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
#elif V8_OS_POSIX
Semaphore::Semaphore(int count) {
// The sem_init() does not check for alignment of the native handle.
// Unaligned native handle can later cause a failure in semaphore signal.
// Check the alignment here to catch the failure earlier.
// Context: crbug.com/605349.
const uintptr_t kPointerAlignmentMask = sizeof(void*) - 1;
CHECK_EQ(
0, reinterpret_cast<uintptr_t>(&native_handle_) & kPointerAlignmentMask);
DCHECK(count >= 0);
#if V8_LIBC_GLIBC
// sem_init in glibc prior to 2.1 does not zero out semaphores.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment