[vm] Make kernel buffers live exactly as long as their derived views.
When creating a KernelProgramInfo, we create several logical views into the kernel buffer. These are fresh ExternalTypedDatas, rather than proper TypedDataViews, so they do not automically keep the original ExternalTypedData alive. Create an explicit reference to the orginal ExternalTypedData in the KernelProgramInfo. When creating snapshots, this reference is ignored/null'd and the views are turned into copies, effectively dropping the parts of the original buffer that do not have views. Fixes a leak with reload and a use-after-free with eval. Bug: https://github.com/dart-lang/sdk/issues/33973 Bug: https://github.com/dart-lang/sdk/issues/39610 Change-Id: I09d3830133314ccbaa0341d904127c2b6925c4ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126825 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
5ecfd7058a
commit
f4e44dd705
@@ -124,6 +124,7 @@ std::unique_ptr<Program> Program::ReadFrom(Reader* reader, const char** error) {
|
||||
|
||||
std::unique_ptr<Program> program(new Program());
|
||||
program->binary_version_ = formatVersion;
|
||||
program->typed_data_ = reader->typed_data();
|
||||
program->kernel_data_ = reader->buffer();
|
||||
program->kernel_data_size_ = reader->size();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user