Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1752703) for causing spider-monkey failu…
Browse files Browse the repository at this point in the history
…res in /mozglue/interposers/env_interposer.cpp CLOSED TREE

Backed out changeset 621d691fcf43 (bug 1752703)
Backed out changeset a53bc961d958 (bug 1752703)
  • Loading branch information
Sandor Molnar committed May 10, 2023
1 parent 1fa9fe4 commit 0fa06ef
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 177 deletions.
5 changes: 5 additions & 0 deletions browser/app/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand Down
5 changes: 5 additions & 0 deletions ipc/app/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand Down
1 change: 0 additions & 1 deletion js/src/make-source-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def parse_version(topsrc_dir):
+ /mozglue/baseprofiler/**
+ /mozglue/build/**
+ /mozglue/interposers/**
+ /mozglue/misc/**
+ /mozglue/moz.build
+ /mozglue/static/**
Expand Down
5 changes: 5 additions & 0 deletions js/xpconnect/shell/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
66 changes: 0 additions & 66 deletions mozglue/interposers/InterposerHelper.h

This file was deleted.

78 changes: 0 additions & 78 deletions mozglue/interposers/env_interposer.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions mozglue/interposers/moz.build

This file was deleted.

3 changes: 0 additions & 3 deletions mozglue/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions toolkit/crashreporter/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
12 changes: 12 additions & 0 deletions toolkit/crashreporter/pthread_create_interposer/moz.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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("pthread_create_interposer")

NoVisibilityFlags()

UNIFIED_SOURCES += [
"pthread_create_interposer.cpp",
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <algorithm>

#include <dlfcn.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
Expand All @@ -12,8 +13,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/DebugOnly.h"

#include "InterposerHelper.h"

using mozilla::DebugOnly;

struct SigAltStack {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 0fa06ef

Please sign in to comment.