Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reland workaround for perf-basic-prof filename truncation issue #3520

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 7 additions & 5 deletions deps/v8/src/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,19 @@ class CodeEventLogger::NameBuffer {
}

void AppendInt(int n) {
Vector<char> buffer(utf8_buffer_ + utf8_pos_,
kUtf8BufferSize - utf8_pos_);
int space = kUtf8BufferSize - utf8_pos_;
if (space <= 0) return;
Vector<char> buffer(utf8_buffer_ + utf8_pos_, space);
int size = SNPrintF(buffer, "%d", n);
if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) {
utf8_pos_ += size;
}
}

void AppendHex(uint32_t n) {
Vector<char> buffer(utf8_buffer_ + utf8_pos_,
kUtf8BufferSize - utf8_pos_);
int space = kUtf8BufferSize - utf8_pos_;
if (space <= 0) return;
Vector<char> buffer(utf8_buffer_ + utf8_pos_, space);
int size = SNPrintF(buffer, "%x", n);
if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) {
utf8_pos_ += size;
Expand All @@ -147,7 +149,7 @@ class CodeEventLogger::NameBuffer {

private:
static const int kUtf8BufferSize = 512;
static const int kUtf16BufferSize = 128;
static const int kUtf16BufferSize = kUtf8BufferSize;

int utf8_pos_;
char utf8_buffer_[kUtf8BufferSize];
Expand Down
55 changes: 55 additions & 0 deletions deps/v8/test/cctest/test-log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,58 @@ TEST(LogVersion) {
}
isolate->Dispose();
}


// https://crbug.com/539892
// CodeCreateEvents with really large names should not crash.
TEST(Issue539892) {
class : public i::CodeEventLogger {
public:
virtual void CodeMoveEvent(Address from, Address to) {}
virtual void CodeDeleteEvent(Address from) {}
virtual void CodeDisableOptEvent(i::Code* code,
i::SharedFunctionInfo* shared) {}

private:
virtual void LogRecordedBuffer(i::Code* code, i::SharedFunctionInfo* shared,
const char* name, int length) {}
} code_event_logger;
SETUP_FLAGS();
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);

{
ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
Logger* logger = initialize_logger.logger();
logger->addCodeEventListener(&code_event_logger);

// Function with a really large name.
const char* source_text =
"(function "
"baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaa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