mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Backed out changeset 8b644e916589 (bug 1752703) for causing Android startup crashes (bug 1807716)
This commit is contained in:
parent
7b43afa0de
commit
9274f4e6f3
@ -53,6 +53,11 @@ LOCAL_INCLUDES += [
|
||||
"/xpcom/build",
|
||||
]
|
||||
|
||||
# The pthred_create() interposer needs to be linked as early as possible so
|
||||
# that it will appear before libpthread when resolving symbols.
|
||||
if CONFIG["OS_ARCH"] == "Linux" and CONFIG["MOZ_CRASHREPORTER"]:
|
||||
USE_LIBS += ["pthread_create_interposer"]
|
||||
|
||||
if CONFIG["LIBFUZZER"]:
|
||||
USE_LIBS += ["fuzzer"]
|
||||
LOCAL_INCLUDES += [
|
||||
|
@ -16,6 +16,11 @@ else:
|
||||
"MozillaRuntimeMain.cpp",
|
||||
]
|
||||
|
||||
# The pthred_create() interposer needs to be linked as early as possible so
|
||||
# that it will appear before libpthread when resolving symbols.
|
||||
if CONFIG["OS_ARCH"] == "Linux" and CONFIG["MOZ_CRASHREPORTER"]:
|
||||
USE_LIBS += ["pthread_create_interposer"]
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
|
@ -155,7 +155,6 @@ rsync_filter_list = """
|
||||
|
||||
+ /mozglue/baseprofiler/**
|
||||
+ /mozglue/build/**
|
||||
+ /mozglue/interposers/**
|
||||
+ /mozglue/misc/**
|
||||
+ /mozglue/moz.build
|
||||
+ /mozglue/static/**
|
||||
|
@ -10,6 +10,11 @@ SOURCES += [
|
||||
"xpcshell.cpp",
|
||||
]
|
||||
|
||||
# The pthred_create() interposer needs to be linked as early as possible so
|
||||
# that it will appear before libpthread when resolving symbols.
|
||||
if CONFIG["OS_ARCH"] == "Linux" and CONFIG["MOZ_CRASHREPORTER"]:
|
||||
USE_LIBS += ["pthread_create_interposer"]
|
||||
|
||||
if CONFIG["LIBFUZZER"]:
|
||||
USE_LIBS += ["fuzzer"]
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
/* 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 InterposerHelper_h
|
||||
#define InterposerHelper_h
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
template <typename T>
|
||||
static T get_real_symbol(const char* aName, T aReplacementSymbol) {
|
||||
// T can only be a function pointer
|
||||
static_assert(std::is_function<typename std::remove_pointer<T>::type>::value);
|
||||
|
||||
// Find the corresponding function in the linked libraries
|
||||
T real_symbol = reinterpret_cast<T>(dlsym(RTLD_NEXT, aName));
|
||||
|
||||
if (real_symbol == nullptr) {
|
||||
MOZ_CRASH_UNSAFE_PRINTF(
|
||||
"%s() interposition failed but the interposer function is "
|
||||
"still being called, this won't work!",
|
||||
aName);
|
||||
}
|
||||
|
||||
if (real_symbol == aReplacementSymbol) {
|
||||
MOZ_CRASH_UNSAFE_PRINTF(
|
||||
"We could not obtain the real %s(). Calling the symbol we "
|
||||
"got would make us enter an infinite loop so stop here instead.",
|
||||
aName);
|
||||
}
|
||||
|
||||
return real_symbol;
|
||||
}
|
||||
|
||||
#define GET_REAL_SYMBOL(name) get_real_symbol(#name, name)
|
||||
|
||||
#endif // InterposerHelper_h
|
@ -13,9 +13,6 @@ if CONFIG["MOZ_LINKER"] or CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
|
||||
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
|
||||
DIRS += ["android"]
|
||||
|
||||
if CONFIG["OS_ARCH"] == "Linux":
|
||||
DIRS += ["interposers"]
|
||||
|
||||
DIRS += [
|
||||
"baseprofiler",
|
||||
"build",
|
||||
|
@ -53,6 +53,7 @@ if CONFIG["MOZ_CRASHREPORTER"]:
|
||||
"google-breakpad/src/common",
|
||||
"google-breakpad/src/common/linux",
|
||||
"google-breakpad/src/processor",
|
||||
"pthread_create_interposer",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_OXIDIZED_BREAKPAD"]:
|
||||
|
@ -3,13 +3,10 @@
|
||||
# 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/.
|
||||
Library("interposers")
|
||||
Library("pthread_create_interposer")
|
||||
|
||||
DEFINES["IMPL_MFBT"] = True
|
||||
NoVisibilityFlags()
|
||||
|
||||
if CONFIG["MOZ_CRASHREPORTER"]:
|
||||
UNIFIED_SOURCES += [
|
||||
"pthread_create_interposer.cpp",
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = "mozglue"
|
||||
UNIFIED_SOURCES += [
|
||||
"pthread_create_interposer.cpp",
|
||||
]
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
@ -12,8 +13,6 @@
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "InterposerHelper.h"
|
||||
|
||||
using mozilla::DebugOnly;
|
||||
|
||||
struct SigAltStack {
|
||||
@ -84,12 +83,30 @@ void* set_alt_signal_stack_and_start(PthreadCreateParams* params) {
|
||||
return thread_rv;
|
||||
}
|
||||
|
||||
using pthread_create_func_t = int (*)(pthread_t*, const pthread_attr_t*,
|
||||
void* (*)(void*), void*);
|
||||
|
||||
extern "C" {
|
||||
// This interposer replaces libpthread's pthread_create() so that we can
|
||||
// inject an alternate signal stack in every new thread.
|
||||
MFBT_API int pthread_create(pthread_t* thread, const pthread_attr_t* attr,
|
||||
void* (*start_routine)(void*), void* arg) {
|
||||
static const auto real_pthread_create = GET_REAL_SYMBOL(pthread_create);
|
||||
__attribute__((visibility("default"))) int pthread_create(
|
||||
pthread_t* thread, const pthread_attr_t* attr,
|
||||
void* (*start_routine)(void*), void* arg) {
|
||||
// static const pthread_create_func_t real_pthread_create =
|
||||
static const pthread_create_func_t real_pthread_create =
|
||||
(pthread_create_func_t)dlsym(RTLD_NEXT, "pthread_create");
|
||||
|
||||
if (real_pthread_create == nullptr) {
|
||||
MOZ_CRASH(
|
||||
"pthread_create() interposition failed but the interposer function is "
|
||||
"still being called, this won't work!");
|
||||
}
|
||||
|
||||
if (real_pthread_create == pthread_create) {
|
||||
MOZ_CRASH(
|
||||
"We could not obtain the real pthread_create(). Calling the symbol we "
|
||||
"got would make us enter an infinte loop so stop here instead.");
|
||||
}
|
||||
|
||||
PthreadCreateParams* params =
|
||||
(PthreadCreateParams*)malloc(sizeof(PthreadCreateParams));
|
Loading…
Reference in New Issue
Block a user