Backed out changeset 98e368b5c4be (bug 1463035) for failures in tools/profiler/tests/chrome/test_profile_worker.html on a CLOSED TREE

This commit is contained in:
Noemi Erli 2018-05-22 03:16:44 +03:00
parent d90361a8a7
commit 5ffb086f4a
3 changed files with 51 additions and 1 deletions

45
mfbt/LinuxSignal.h Normal file
View file

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_LinuxSignal_h
#define mozilla_LinuxSignal_h
namespace mozilla {
#if defined(__arm__)
// Some (old) Linux kernels on ARM have a bug where a signal handler
// can be called without clearing the IT bits in CPSR first. The result
// is that the first few instructions of the handler could be skipped,
// ultimately resulting in crashes. To workaround this bug, the handler
// on ARM is a trampoline that starts with enough NOP instructions, so
// that even if the IT bits are not cleared, only the NOP instructions
// will be skipped over.
template <void (*H)(int, siginfo_t*, void*)>
__attribute__((naked)) void
SignalTrampoline(int aSignal, siginfo_t* aInfo, void* aContext)
{
asm volatile (
"nop; nop; nop; nop"
: : : "memory");
asm volatile (
"b %0"
:
: "X"(H)
: "memory");
}
# define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
#else // __arm__
# define MOZ_SIGNAL_TRAMPOLINE(h) (h)
#endif // __arm__
} // namespace mozilla
#endif // mozilla_LinuxSignal_h

View file

@ -122,6 +122,10 @@ if CONFIG['OS_ARCH'] == 'WINNT':
EXPORTS.mozilla += [
'WindowsVersion.h',
]
elif CONFIG['OS_ARCH'] == 'Linux':
EXPORTS.mozilla += [
'LinuxSignal.h',
]
UNIFIED_SOURCES += [
'Assertions.cpp',

View file

@ -60,6 +60,7 @@
#include <stdarg.h>
#include "prenv.h"
#include "mozilla/LinuxSignal.h"
#include "mozilla/PodOperations.h"
#include "mozilla/DebugOnly.h"
@ -276,7 +277,7 @@ Sampler::Sampler(PSLockRef aLock)
// Request profiling signals.
struct sigaction sa;
sa.sa_sigaction = SigprofHandler;
sa.sa_sigaction = MOZ_SIGNAL_TRAMPOLINE(SigprofHandler);
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART | SA_SIGINFO;
if (sigaction(SIGPROF, &sa, &mOldSigprofHandler) != 0) {