Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test-app/runtime/src/main/cpp/WorkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void WorkerWrapper::Terminate() {
// A worker paused at a breakpoint sits in the inspector's nested pause
// loop, not in Looper.loop() - kick it loose so TerminateExecution and
// the looper quit below can take effect.
std::lock_guard<std::mutex> lock(inspectorMutex_);
std::lock_guard<std::recursive_mutex> lock(inspectorMutex_);
if (inspector_ != nullptr) {
inspector_->NotifyTerminating();
}
Expand Down Expand Up @@ -810,7 +810,7 @@ void WorkerWrapper::CreateInspector(Isolate* isolate) {

auto* client = new WorkerInspectorClient(workerId_, isolate, ALooper_forThread(), url);
{
std::lock_guard<std::mutex> lock(inspectorMutex_);
std::lock_guard<std::recursive_mutex> lock(inspectorMutex_);
inspector_ = client;
}

Expand All @@ -822,7 +822,7 @@ void WorkerWrapper::CreateInspector(Isolate* isolate) {
void WorkerWrapper::DestroyInspector() {
WorkerInspectorClient* client = nullptr;
{
std::lock_guard<std::mutex> lock(inspectorMutex_);
std::lock_guard<std::recursive_mutex> lock(inspectorMutex_);
client = inspector_;
inspector_ = nullptr;
}
Expand All @@ -843,7 +843,7 @@ void WorkerWrapper::DestroyInspector() {

void WorkerWrapper::ConsoleLog(v8_inspector::ConsoleAPIType method,
const std::vector<Local<Value>>& args) {
std::lock_guard<std::mutex> lock(inspectorMutex_);
std::lock_guard<std::recursive_mutex> lock(inspectorMutex_);
if (inspector_ != nullptr) {
inspector_->consoleLog(method, args);
}
Expand Down
5 changes: 4 additions & 1 deletion test-app/runtime/src/main/cpp/WorkerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ class WorkerWrapper : public std::enable_shared_from_this<WorkerWrapper> {
void DestroyInspector();

WorkerInspectorClient* inspector_ = nullptr;
std::mutex inspectorMutex_;
// Recursive: ConsoleLog holds it across consoleLog, whose stack capture
// allocates, and a near-heap-limit callback raised by that allocation
// calls Terminate(), which takes it again on the same thread.
std::recursive_mutex inspectorMutex_;
#endif

static std::mutex registryMutex_;
Expand Down
Loading