chromium/v8/test/unittests/libsampler/signals-and-mutexes-unittest.cc

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <signal.h>

#include "src/base/platform/mutex.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/utils/random-number-generator.h"
#include "src/libsampler/sampler.h"  // for USE_SIGNALS
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {

using SignalAndMutexTest = TestWithContext;
namespace sampler {

// There seem to be problems with pthread_rwlock_t and signal handling on
// Mac, see https://crbug.com/v8/11399 and
// https://stackoverflow.com/questions/22643374/deadlock-with-pthread-rwlock-t-and-signals
// This test reproduces it, and can be used to test if this problem is fixed in
// future Mac releases.
// Note: For now, we fall back to using pthread_mutex_t to implement SharedMutex
// on Mac, so this test succeeds.

#ifdef USE_SIGNALS

void HandleProfilerSignal(int signal, siginfo_t*, void*) {}

struct sigaction old_signal_handler;

void InstallSignalHandler() {}

static void RestoreSignalHandler() {}

TEST_F(SignalAndMutexTest, SignalsPlusSharedMutexes) {}

#endif  // USE_SIGNALS

}  // namespace sampler
}  // namespace v8