Sanitize nullptr name in wasm profiling events.

For some wasm functions, name information is not available, resulting
in a nullptr being passed to the profiling event listener. While we
probably should have better names, this at least prevents a crash.

Change-Id: I41bd7827124e9c193a076a57d3a134f5df1d6a15
Reviewed-on: https://chromium-review.googlesource.com/926367
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51396}
This commit is contained in:
Stephan Herhut 2018-02-20 16:46:34 +01:00 committed by Commit Bot
parent 07abe39aed
commit 6e547e907e

View File

@ -118,11 +118,14 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->instructions().start();
// TODO(herhut): Instead of sanitizing here, make sure all wasm functions
// have names.
const char* name_ptr =
name.start() == nullptr ? "<anonymous>" : GetFunctionName(name.start());
rec->entry = NewCodeEntry(
tag, GetFunctionName(name.start()), CodeEntry::kEmptyNamePrefix,
CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoColumnNumberInfo, nullptr,
code->instructions().start());
tag, name_ptr, CodeEntry::kEmptyNamePrefix, CodeEntry::kEmptyResourceName,
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
nullptr, code->instructions().start());
rec->size = code->instructions().length();
DispatchCodeEvent(evt_rec);
}