forked from mirrors/gecko-dev
Backed out 3 changesets (bug 1791682) for causing spider monkey failures. CLOSED TREE
Backed out changeset c7e6bf99e7f7 (bug 1791682) Backed out changeset 5be243995b2f (bug 1791682) Backed out changeset a2e1831539e7 (bug 1791682)
This commit is contained in:
parent
70bc1e8b84
commit
864b7a93a2
5 changed files with 84 additions and 189 deletions
|
|
@ -194,34 +194,17 @@ AST_MATCHER(CallExpr, isInWhiteListForPrincipalGetUri) {
|
||||||
/// code or names of existing threads that we would like to ignore.
|
/// code or names of existing threads that we would like to ignore.
|
||||||
AST_MATCHER(CallExpr, isInAllowlistForThreads) {
|
AST_MATCHER(CallExpr, isInAllowlistForThreads) {
|
||||||
|
|
||||||
// Get the source location of the call.
|
// Get the source location of the call
|
||||||
SourceLocation Loc = Node.getRParenLoc();
|
SourceLocation Loc = Node.getRParenLoc();
|
||||||
StringRef FileName =
|
StringRef FileName =
|
||||||
getFilename(Finder->getASTContext().getSourceManager(), Loc);
|
getFilename(Finder->getASTContext().getSourceManager(), Loc);
|
||||||
|
|
||||||
const auto rbegin = [](StringRef s) { return llvm::sys::path::rbegin(s); };
|
|
||||||
const auto rend = [](StringRef s) { return llvm::sys::path::rend(s); };
|
|
||||||
|
|
||||||
// Files in the allowlist are (definitionally) explicitly permitted to create
|
|
||||||
// new threads.
|
|
||||||
for (auto thread_file : allow_thread_files) {
|
for (auto thread_file : allow_thread_files) {
|
||||||
// All the provided path-elements must match.
|
if (llvm::sys::path::rbegin(FileName)->equals(thread_file)) {
|
||||||
const bool match = [&] {
|
|
||||||
auto it1 = rbegin(FileName), it2 = rbegin(thread_file),
|
|
||||||
end1 = rend(FileName), end2 = rend(thread_file);
|
|
||||||
for (; it2 != end2; ++it1, ++it2) {
|
|
||||||
if (it1 == end1 || !it1->equals(*it2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}();
|
|
||||||
if (match) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the first arg (the name of the thread).
|
// Now we get the first arg (the name of the thread) and we check it.
|
||||||
const StringLiteral *nameArg =
|
const StringLiteral *nameArg =
|
||||||
dyn_cast<StringLiteral>(Node.getArg(0)->IgnoreImplicit());
|
dyn_cast<StringLiteral>(Node.getArg(0)->IgnoreImplicit());
|
||||||
if (nameArg) {
|
if (nameArg) {
|
||||||
|
|
|
||||||
|
|
@ -2,78 +2,58 @@
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import posixpath
|
|
||||||
|
|
||||||
from os import PathLike
|
FIRST_LINE = "// This file was generated by generate_thread_allows.py. DO NOT EDIT."
|
||||||
from typing import Iterable, Literal, Set
|
|
||||||
|
|
||||||
FIRST_LINE = "// This file was generated by {}. DO NOT EDIT.".format(
|
|
||||||
# `posixpath` for forward slashes, for presentation purposes
|
|
||||||
posixpath.relpath(__file__, os.getenv("TOPSRCDIR", "/"))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_allowed_items(
|
def generate_allows(input_paths):
|
||||||
which: Literal["files", "names"], paths: Iterable[PathLike]
|
"""
|
||||||
) -> str:
|
This script reads in the ThreadAllows.txt and ThreadFileAllows.txt lists
|
||||||
def remove_trailing_comment(s: str) -> str:
|
and generates a header file containing a two arrays of allowed threads.
|
||||||
return s[0 : s.find("#")]
|
These can be the following formats:
|
||||||
|
-Files which the checker should ignore
|
||||||
|
These files either contain definitions of NS_NewNamedThread or
|
||||||
|
use args which the plugin can't cast (such as func args).
|
||||||
|
-Thread names which the checker should ignore
|
||||||
|
Specifies which individual thread names to ignore.
|
||||||
|
"""
|
||||||
|
file_list = []
|
||||||
|
name_list = []
|
||||||
|
lines = set()
|
||||||
|
|
||||||
def read_items_from_path(path: PathLike) -> Set[str]:
|
for path in input_paths:
|
||||||
out = set()
|
|
||||||
with open(path) as file:
|
with open(path) as file:
|
||||||
for line in file.readlines():
|
lines.update(file.readlines())
|
||||||
line = remove_trailing_comment(line).strip()
|
|
||||||
if not line:
|
|
||||||
continue # comment or empty line; discard
|
|
||||||
out.add(line)
|
|
||||||
return out
|
|
||||||
|
|
||||||
allowed = set().union(*(read_items_from_path(path) for path in paths))
|
for line in sorted(lines):
|
||||||
# BUG: `json.dumps` may not correctly handle use of the quote character in
|
"""
|
||||||
# thread names
|
We are assuming lines ending in .cpp, .h are files. Threads should
|
||||||
allowed_list_s = ",\n ".join(json.dumps(elem) for elem in sorted(allowed))
|
NOT have names containing filenames. Please don't do that.
|
||||||
|
"""
|
||||||
return f"""\
|
line = line.strip()
|
||||||
static const char *allow_thread_{which}[] = {{
|
if line.endswith(".cpp") or line.endswith(".h"):
|
||||||
{allowed_list_s}
|
file_list.append(line)
|
||||||
}};"""
|
else:
|
||||||
|
name_list.append(line)
|
||||||
|
file_list_s = ",\n ".join(json.dumps(elem) for elem in file_list)
|
||||||
def generate_allows(
|
name_list_s = ",\n ".join(json.dumps(elem) for elem in name_list)
|
||||||
*, allowed_names: Iterable[PathLike], allowed_files: Iterable[PathLike]
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
This function reads in the specified sets of files -- ordinarily,
|
|
||||||
["ThreadAllows.txt"] and ["ThreadFileAllows.txt"] -- and generates the text
|
|
||||||
of a header file containing two arrays with their contents, for inclusion by
|
|
||||||
the thread-name checker.
|
|
||||||
|
|
||||||
The checker will reject the creation of any thread via NS_NewNamedThread
|
|
||||||
unless either:
|
|
||||||
- the thread's name is a literal string which is found in the set of
|
|
||||||
allowed thread names; or
|
|
||||||
- the thread's creation occurs within a file which is found in the set of
|
|
||||||
unchecked files.
|
|
||||||
|
|
||||||
The latter condition exists mostly for the definition of NS_NewNamedThread,
|
|
||||||
but there also exist a few cases where the thread name is dynamically
|
|
||||||
computed (and so can't be checked).
|
|
||||||
"""
|
|
||||||
output_string = (
|
output_string = (
|
||||||
FIRST_LINE
|
FIRST_LINE
|
||||||
+ "\n\n"
|
+ """
|
||||||
+ generate_allowed_items("files", allowed_files)
|
|
||||||
+ "\n\n"
|
static const char *allow_thread_files[] = {
|
||||||
+ generate_allowed_items("names", allowed_names)
|
%s
|
||||||
+ "\n"
|
};
|
||||||
|
|
||||||
|
static const char *allow_thread_names[] = {
|
||||||
|
%s
|
||||||
|
};
|
||||||
|
|
||||||
|
"""
|
||||||
|
% (file_list_s, name_list_s)
|
||||||
)
|
)
|
||||||
return output_string
|
return output_string
|
||||||
|
|
||||||
|
|
||||||
# Entry point used by build/clang-plugin/moz.build (q.v.).
|
def generate_file(output, *input_paths):
|
||||||
def generate_file(output, allowed_names, allowed_files):
|
output.write(generate_allows(input_paths))
|
||||||
output.write(
|
|
||||||
generate_allows(allowed_names=[allowed_names], allowed_files=[allowed_files])
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,11 @@
|
||||||
# This file is ingested by `ThreadAllows.py` to produce a list of thread names
|
ApplyUpdates
|
||||||
# which our clang plugin will allow to be used with `NS_NewNamedThread`.
|
AsyncShutdownPr
|
||||||
#
|
AsyncShutdownWt
|
||||||
# Permitted thread names are a maximum of 15 characters in length, and must be
|
Atom Test
|
||||||
# string literals at their point-of-use in the code -- i.e., in the invocation
|
AutoRefCnt Test
|
||||||
# of `NS_NewNamedThread`.
|
AutoTestThread
|
||||||
#
|
AwaitIdleMixed
|
||||||
# Within this file, each permitted thread name is on a separate line. Comments
|
AwaitIdlePaused
|
||||||
# begin with `#`, as seen here. Leading and trailing whitespace, trailing
|
|
||||||
# comments, and blank lines are ignored, and may be used freely.
|
|
||||||
#
|
|
||||||
# Please explain the addition of any new thread names in comments, preferably
|
|
||||||
# with a pointer to a relevant bug. (Do not add thread names only used in tests
|
|
||||||
# to this file; instead, add the test file to `ThreadFileAllows.txt`.)
|
|
||||||
|
|
||||||
######
|
|
||||||
# Gecko/Firefox thread names
|
|
||||||
#
|
|
||||||
# (None documented yet -- but see "Unsorted thread names", below.)
|
|
||||||
|
|
||||||
######
|
|
||||||
# Thunderbird-only thread names
|
|
||||||
IMAP
|
|
||||||
|
|
||||||
######
|
|
||||||
# Other
|
|
||||||
Checker Test # used only as part of tests for the thread-checker itself
|
|
||||||
|
|
||||||
######
|
|
||||||
# Unsorted thread names
|
|
||||||
#
|
|
||||||
# Thread names below this point are grandfathered in. Please do not add new
|
|
||||||
# thread names to this list -- and please remove any that you can, whether by
|
|
||||||
# documenting and moving them or by confirming that they are no longer required.
|
|
||||||
#
|
|
||||||
# In particular, if a thread name is only used for testing, please consider
|
|
||||||
# moving its declarator to `ThreadFileAllows.txt`.
|
|
||||||
|
|
||||||
BGReadURLs
|
BGReadURLs
|
||||||
BHMgr Monitor
|
BHMgr Monitor
|
||||||
BHMgr Processor
|
BHMgr Processor
|
||||||
|
|
@ -44,6 +14,9 @@ COM MTA
|
||||||
Cache I/O
|
Cache I/O
|
||||||
Cameras IPC
|
Cameras IPC
|
||||||
CanvasRenderer
|
CanvasRenderer
|
||||||
|
ChainedPipePump
|
||||||
|
ChainedPipeRecv
|
||||||
|
Checker Test
|
||||||
Compositor
|
Compositor
|
||||||
Cookie
|
Cookie
|
||||||
CrashRep Inject
|
CrashRep Inject
|
||||||
|
|
@ -51,21 +24,29 @@ DDMediaLogs
|
||||||
DOMCacheThread
|
DOMCacheThread
|
||||||
DataChannel IO
|
DataChannel IO
|
||||||
DataStorage
|
DataStorage
|
||||||
|
DatabaseLocker
|
||||||
|
DecodeToSurface
|
||||||
|
Decoder Test
|
||||||
FileWatcher IO
|
FileWatcher IO
|
||||||
Font Loader
|
Font Loader
|
||||||
FontEnumThread
|
FontEnumThread
|
||||||
Function Broker
|
Function Broker
|
||||||
GMPThread
|
GMPThread
|
||||||
Gamepad
|
Gamepad
|
||||||
|
GeckoProfGTest
|
||||||
GraphRunner
|
GraphRunner
|
||||||
HTML5 Parser
|
HTML5 Parser
|
||||||
ICS parser
|
ICS parser
|
||||||
|
IMAP
|
||||||
IPC Launch
|
IPC Launch
|
||||||
|
IPCFuzzLoop
|
||||||
IPDL Background
|
IPDL Background
|
||||||
|
IPDL UnitTest
|
||||||
IdentityCrypto
|
IdentityCrypto
|
||||||
ImageBridgeChld
|
ImageBridgeChld
|
||||||
LS Thread
|
LS Thread
|
||||||
MDCDMThread
|
MDCDMThread
|
||||||
|
MWQThread
|
||||||
MediaCache
|
MediaCache
|
||||||
MediaTelemetry
|
MediaTelemetry
|
||||||
MediaTrackGrph
|
MediaTrackGrph
|
||||||
|
|
@ -83,16 +64,28 @@ ProfSymbolTable
|
||||||
ProfilerChild
|
ProfilerChild
|
||||||
ProxyResolution
|
ProxyResolution
|
||||||
RemoteLzyStream
|
RemoteLzyStream
|
||||||
|
RWLockTester
|
||||||
|
RacingServMan
|
||||||
RemVidChild
|
RemVidChild
|
||||||
Renderer
|
Renderer
|
||||||
ResetCleanup
|
ResetCleanup
|
||||||
|
Sandbox Testing
|
||||||
SaveScripts
|
SaveScripts
|
||||||
Socket Thread
|
Socket Thread
|
||||||
SpeechWorker
|
SpeechWorker
|
||||||
|
SpinEventLoop
|
||||||
StressRunner
|
StressRunner
|
||||||
SuicideManager
|
SuicideManager
|
||||||
|
SuicideThread
|
||||||
System Proxy
|
System Proxy
|
||||||
|
TEQ AwaitIdle
|
||||||
TelemetryModule
|
TelemetryModule
|
||||||
|
Test Thread
|
||||||
|
Test thread
|
||||||
|
TestPipe
|
||||||
|
TestShortWrites
|
||||||
|
TestThreadsMain
|
||||||
|
Testing Thread
|
||||||
Timer
|
Timer
|
||||||
ToastBgThread
|
ToastBgThread
|
||||||
TRR Background
|
TRR Background
|
||||||
|
|
@ -103,6 +96,8 @@ VsyncIOThread
|
||||||
Wifi Monitor
|
Wifi Monitor
|
||||||
Worker Launcher
|
Worker Launcher
|
||||||
speechd init
|
speechd init
|
||||||
|
t1
|
||||||
|
t2
|
||||||
thread
|
thread
|
||||||
thread shutdown
|
thread shutdown
|
||||||
wifi tickler
|
wifi tickler
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,4 @@
|
||||||
# This file is ingested by `ThreadAllows.py` to produce a list of files which
|
ActorsParent.cpp
|
||||||
# our clang plugin will allow to use `NS_NewNamedThread`.
|
|
||||||
#
|
|
||||||
# Files may be specified with any number of slash-separated path-elements; all
|
|
||||||
# provided path-elements must match. (Because we often move and/or symlink
|
|
||||||
# header files, this means headers will usually have no path-elements.)
|
|
||||||
#
|
|
||||||
# Note that this file contains a list of _files_, not _paths_. The clang plugin
|
|
||||||
# has no notion of $TOPSRCDIR.
|
|
||||||
|
|
||||||
######
|
|
||||||
# Release files
|
|
||||||
|
|
||||||
# declaration and definition of `NS_NewNamedThread`
|
|
||||||
nsThreadUtils.h
|
|
||||||
xpcom/threads/nsThreadUtils.cpp
|
|
||||||
|
|
||||||
# Thread-pools are permitted to make dynamically many threads, using dynamic
|
|
||||||
# thread names with explicit numbering.
|
|
||||||
xpcom/threads/nsThreadPool.cpp
|
|
||||||
|
|
||||||
######
|
|
||||||
# Test files
|
|
||||||
|
|
||||||
# Tests for XPCOM threads themselves.
|
|
||||||
xpcom/tests/gtest/TestThreadManager.cpp
|
|
||||||
xpcom/tests/gtest/TestThreads.cpp
|
|
||||||
xpcom/tests/gtest/TestThreadUtils.cpp
|
|
||||||
|
|
||||||
######
|
|
||||||
# Unsorted release files
|
|
||||||
#
|
|
||||||
# Files below this point are grandfathered in. Please do not add new files to
|
|
||||||
# this list -- and please remove any that you can, whether by documenting and
|
|
||||||
# moving them or by confirming that they are no longer required.
|
|
||||||
dom/indexedDB/ActorsParent.cpp
|
|
||||||
dom/quota/ActorsParent.cpp
|
|
||||||
DecodePool.cpp
|
DecodePool.cpp
|
||||||
GeckoChildProcessHost.cpp
|
GeckoChildProcessHost.cpp
|
||||||
LazyIdleThread.cpp
|
LazyIdleThread.cpp
|
||||||
|
|
@ -42,31 +6,6 @@ LazyIdleThread.h
|
||||||
VRThread.cpp
|
VRThread.cpp
|
||||||
mozStorageConnection.cpp
|
mozStorageConnection.cpp
|
||||||
nr_socket_prsock.cpp
|
nr_socket_prsock.cpp
|
||||||
|
nsThreadPool.cpp
|
||||||
######
|
nsThreadUtils.cpp
|
||||||
# Unsorted test files
|
nsThreadUtils.h
|
||||||
#
|
|
||||||
# Files below this point are quasi-grandfathered in: these are test files which
|
|
||||||
# create new threads whose names were formerly in ThreadAllows.txt (without
|
|
||||||
# justification), and have been moved here (without justification).
|
|
||||||
dom/media/doctor/test/gtest/TestMultiWriterQueue.cpp
|
|
||||||
image/test/fuzzing/TestDecoders.cpp
|
|
||||||
image/test/gtest/TestDecodeToSurface.cpp
|
|
||||||
ipc/ipdl/test/gtest/IPDLUnitTest.cpp
|
|
||||||
security/sandbox/common/test/SandboxTestingThread.h
|
|
||||||
storage/test/gtest/test_interruptSynchronousConnection.cpp
|
|
||||||
storage/test/gtest/test_unlock_notify.cpp
|
|
||||||
toolkit/components/telemetry/geckoview/gtest/TestGeckoViewStreaming.cpp
|
|
||||||
toolkit/components/telemetry/tests/gtest/TestScalars.cpp
|
|
||||||
toolkit/components/url-classifier/tests/gtest/Common.cpp
|
|
||||||
tools/fuzzing/ipc/IPCFuzzController.cpp
|
|
||||||
tools/profiler/tests/gtest/GeckoProfiler.cpp
|
|
||||||
xpcom/tests/gtest/TestAtoms.cpp
|
|
||||||
xpcom/tests/gtest/TestAutoRefCnt.cpp
|
|
||||||
xpcom/tests/gtest/TestDelayedRunnable.cpp
|
|
||||||
xpcom/tests/gtest/TestLogging.cpp
|
|
||||||
xpcom/tests/gtest/TestPipes.cpp
|
|
||||||
xpcom/tests/gtest/TestRacingServiceManager.cpp
|
|
||||||
xpcom/tests/gtest/TestRWLock.cpp
|
|
||||||
xpcom/tests/gtest/TestThrottledEventQueue.cpp
|
|
||||||
xpcom/tests/gtest/TestTimers.cpp
|
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,7 @@ def generate_thread_allows(mozilla_path, module_path):
|
||||||
names = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadAllows.txt")
|
names = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadAllows.txt")
|
||||||
files = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadFileAllows.txt")
|
files = os.path.join(mozilla_path, "../../build/clang-plugin/ThreadFileAllows.txt")
|
||||||
with open(os.path.join(module_path, "ThreadAllows.h"), "w") as f:
|
with open(os.path.join(module_path, "ThreadAllows.h"), "w") as f:
|
||||||
f.write(
|
f.write(ThreadAllows.generate_allows({files, names}))
|
||||||
ThreadAllows.generate_allows(allowed_names=[names], allowed_files=[files])
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def do_import(mozilla_path, clang_tidy_path, import_options):
|
def do_import(mozilla_path, clang_tidy_path, import_options):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue