Commit 5d253161 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Fix gn CHECK()ing when generating Chromium build files

After r531270, gn chokes while running exec_script():

[0124/122441.126364:FATAL:thread_restrictions.cc(105)] Check failed:
!g_base_sync_primitives_disallowed.Get().Get().

GN executes scripts synchronously while loading files, so blocking is necessary.
This CL adds a ScopedAllowBaseSyncPrimitives for gn to use while waiting for
exec_script() to complete.

BUG=805628
R=dpranke,thestig,fdoray

Change-Id: I7ad539a8dee0230c84d94f1c6b37755a890bfcd7
Reviewed-on: https://chromium-review.googlesource.com/884423
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532069}
parent 36b8d709
......@@ -62,6 +62,9 @@ namespace disk_cache {
class BackendImpl;
class InFlightIO;
}
namespace functions {
class ExecScriptScopedAllowBaseSyncPrimitives;
}
namespace gpu {
class GpuChannelHost;
}
......@@ -267,6 +270,7 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives {
ScopedAllowBaseSyncPrimitivesWithBlockingDisallowed);
friend class base::GetAppOutputScopedAllowBaseSyncPrimitives;
friend class content::SessionStorageDatabase;
friend class functions::ExecScriptScopedAllowBaseSyncPrimitives;
friend class leveldb::LevelDBMojoProxy;
friend class media::BlockingUrlProtocol;
friend class net::MultiThreadedCertVerifierScopedAllowBaseSyncPrimitives;
......
......@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "tools/gn/err.h"
......@@ -115,6 +116,9 @@ Example
exec_script("//foo/bar/myscript.py")
)";
class ExecScriptScopedAllowBaseSyncPrimitives
: public base::ScopedAllowBaseSyncPrimitives {};
Value RunExecScript(Scope* scope,
const FunctionCallNode* function,
const std::vector<Value>& args,
......@@ -221,11 +225,15 @@ Value RunExecScript(Scope* scope,
std::string output;
std::string stderr_output;
int exit_code = 0;
if (!internal::ExecProcess(
cmdline, startup_dir, &output, &stderr_output, &exit_code)) {
*err = Err(function->function(), "Could not execute python.",
"I was trying to execute \"" + FilePathToUTF8(python_path) + "\".");
return Value();
{
ExecScriptScopedAllowBaseSyncPrimitives allow_base_sync_primitives;
if (!internal::ExecProcess(cmdline, startup_dir, &output, &stderr_output,
&exit_code)) {
*err = Err(
function->function(), "Could not execute python.",
"I was trying to execute \"" + FilePathToUTF8(python_path) + "\".");
return Value();
}
}
if (g_scheduler->verbose_logging()) {
g_scheduler->Log("Pythoning", script_source.value() + " took " +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment