[d8] enable os.system only when requested

os.system uses fork(), which is not supported by ASAN/LSAN. Some fuzz tests
consist of js code that randomly picks properties and functions and calls them.
Sometimes, this combination means ASAN will report false positives.

Bug: chromium:740361
Change-Id: Id8d517263251a1fe88abadd33b0225c664b00498
Reviewed-on: https://chromium-review.googlesource.com/580313
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46876}
This commit is contained in:
Mircea Trofin 2017-07-21 11:16:20 -07:00 committed by Commit Bot
parent 0392eb20ac
commit ae5de6184e
4 changed files with 12 additions and 5 deletions

View File

@ -749,9 +749,11 @@ void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {
os_templ->Set(String::NewFromUtf8(isolate, "system", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, System));
if (options.enable_os_system) {
os_templ->Set(String::NewFromUtf8(isolate, "system", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, System));
}
os_templ->Set(String::NewFromUtf8(isolate, "chdir", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, ChangeDirectory));

View File

@ -1,4 +1,4 @@
// Copyright 2012 the V8 project authors. All rights reserved.
/// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -2717,6 +2717,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--disable-in-process-stack-traces") == 0) {
options.disable_in_process_stack_traces = true;
argv[i] = NULL;
} else if (strcmp(argv[i], "--enable-os-system") == 0) {
options.enable_os_system = true;
argv[i] = NULL;
}
}

View File

@ -337,6 +337,7 @@ class ShellOptions {
const char* trace_config;
const char* lcov_file;
bool disable_in_process_stack_traces;
bool enable_os_system = false;
};
class Shell : public i::AllStatic {

View File

@ -33,7 +33,8 @@ if [ ! -x "$d8_exec" ]; then
fi
# nm spits out 'no symbols found' messages to stderr.
cat $log_file | $d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
cat $log_file | $d8_exec --enable-os-system \
$tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/csvparser.js $tools_path/consarray.js \
$tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \