Skip to content

Commit

Permalink
[wasm][liftoff][eh] Fix try info cache state leak
Browse files Browse the repository at this point in the history
Allocate the TryInfo in a unique_ptr to ensure that its destructor is
called when the corresponding control block is popped from the control
stack.
In particular, the cache state allocates memory on the heap which is
otherwise never freed.

[email protected]

Bug: chromium:1185127
Change-Id: I3aee5573f99ef94c13d0649413a4e647a32bc555
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739649
Commit-Queue: Thibaud Michaud <[email protected]>
Reviewed-by: Clemens Backes <[email protected]>
Cr-Commit-Position: refs/heads/master@{#73431}
  • Loading branch information
thibaudmichaud authored and Commit Bot committed Mar 16, 2021
1 parent 26d85ac commit b9ccf86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wasm/baseline/liftoff-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class LiftoffCompiler {
std::unique_ptr<ElseState> else_state;
LiftoffAssembler::CacheState label_state;
MovableLabel label;
TryInfo* try_info = nullptr;
std::unique_ptr<TryInfo> try_info;
// Number of exceptions on the stack below this control.
int num_exceptions = 0;

Expand Down Expand Up @@ -1064,7 +1064,7 @@ class LiftoffCompiler {
}

void Try(FullDecoder* decoder, Control* block) {
block->try_info = compilation_zone_->New<TryInfo>();
block->try_info = std::make_unique<TryInfo>();
block->try_info->previous_catch = current_catch_;
current_catch_ = static_cast<int32_t>(decoder->control_depth() - 1);
PushControl(block);
Expand Down

0 comments on commit b9ccf86

Please sign in to comment.