Commit c8ae9729 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[lsan] Ignore code comments

Code comments are heap-allocated and never freed. We don't want to
attach them to the code object via a finalizer, since that could change
gc timing and heap layout when you enable code comments. They are used
to testing only anyway, so leaking is acceptable here.

R=bmeurer@chromium.org, jarin@chromium.org

Bug: v8:7738
Change-Id: I27b0f95db1d66b57f4f113c154f23edb84e6700d
Reviewed-on: https://chromium-review.googlesource.com/1051241
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53107}
parent c9a728aa
...@@ -2040,6 +2040,7 @@ v8_source_set("v8_base") { ...@@ -2040,6 +2040,7 @@ v8_source_set("v8_base") {
"src/lookup-cache.h", "src/lookup-cache.h",
"src/lookup.cc", "src/lookup.cc",
"src/lookup.h", "src/lookup.h",
"src/lsan.h",
"src/machine-type.cc", "src/machine-type.cc",
"src/machine-type.h", "src/machine-type.h",
"src/macro-assembler-inl.h", "src/macro-assembler-inl.h",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "src/frames.h" #include "src/frames.h"
#include "src/interface-descriptors.h" #include "src/interface-descriptors.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
#include "src/lsan.h"
#include "src/machine-type.h" #include "src/machine-type.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
...@@ -500,6 +501,7 @@ void CodeAssembler::Comment(const char* format, ...) { ...@@ -500,6 +501,7 @@ void CodeAssembler::Comment(const char* format, ...) {
const int prefix_len = 2; const int prefix_len = 2;
int length = builder.position() + 1; int length = builder.position() + 1;
char* copy = reinterpret_cast<char*>(malloc(length + prefix_len)); char* copy = reinterpret_cast<char*>(malloc(length + prefix_len));
LSAN_IGNORE_OBJECT(copy);
MemCopy(copy + prefix_len, builder.Finalize(), length); MemCopy(copy + prefix_len, builder.Finalize(), length);
copy[0] = ';'; copy[0] = ';';
copy[1] = ' '; copy[1] = ' ';
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "src/compiler/wasm-compiler.h" #include "src/compiler/wasm-compiler.h"
#include "src/eh-frame.h" #include "src/eh-frame.h"
#include "src/frames.h" #include "src/frames.h"
#include "src/lsan.h"
#include "src/macro-assembler-inl.h" #include "src/macro-assembler-inl.h"
#include "src/optimized-compilation-info.h" #include "src/optimized-compilation-info.h"
...@@ -210,9 +211,9 @@ void CodeGenerator::AssembleCode() { ...@@ -210,9 +211,9 @@ void CodeGenerator::AssembleCode() {
current_block_ = block->rpo_number(); current_block_ = block->rpo_number();
unwinding_info_writer_.BeginInstructionBlock(tasm()->pc_offset(), block); unwinding_info_writer_.BeginInstructionBlock(tasm()->pc_offset(), block);
if (FLAG_code_comments) { if (FLAG_code_comments) {
// TODO(titzer): these code comments are a giant memory leak.
Vector<char> buffer = Vector<char>::New(200); Vector<char> buffer = Vector<char>::New(200);
char* buffer_start = buffer.start(); char* buffer_start = buffer.start();
LSAN_IGNORE_OBJECT(buffer_start);
int next = SNPrintF( int next = SNPrintF(
buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(), buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(),
...@@ -712,7 +713,9 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) { ...@@ -712,7 +713,9 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
buffer << source_position.InliningStack(info); buffer << source_position.InliningStack(info);
} }
buffer << " --"; buffer << " --";
tasm()->RecordComment(StrDup(buffer.str().c_str())); char* str = StrDup(buffer.str().c_str());
LSAN_IGNORE_OBJECT(str);
tasm()->RecordComment(str);
} }
} }
......
// Copyright 2018 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.
// LeakSanitizer support.
#ifndef V8_LSAN_H_
#define V8_LSAN_H_
#include "src/base/macros.h"
#include "src/globals.h"
// There is no compile time flag for LSan, to enable this whenever ASan is
// enabled. Note that LSan can be used as part of ASan with 'detect_leaks=1'.
#ifdef V8_USE_ADDRESS_SANITIZER
#include <sanitizer/lsan_interface.h>
#define LSAN_IGNORE_OBJECT(ptr) __lsan_ignore_object(ptr)
#else // !V8_USE_ADDRESS_SANITIZER
#define LSAN_IGNORE_OBJECT(ptr) \
static_assert(std::is_pointer<decltype(ptr)>::value || \
std::is_same<v8::internal::Address, decltype(ptr)>::value, \
"static type violation")
#endif // V8_USE_ADDRESS_SANITIZER
#endif // V8_LSAN_H_
...@@ -418,10 +418,6 @@ ...@@ -418,10 +418,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=7102 # https://bugs.chromium.org/p/v8/issues/detail?id=7102
# Flaky due to huge string allocation. # Flaky due to huge string allocation.
'regress/regress-748069': [SKIP], 'regress/regress-748069': [SKIP],
# https://crbug.com/v8/7738
# Code comments currently leak memory.
'code-comments': [SKIP],
}], # 'asan == True' }], # 'asan == True'
############################################################################## ##############################################################################
......
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