Skip to content

Commit b43bb45

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/concurrency] Fix asan memory leak caused by longjmp over std::function<> objects
This is a follow-up to 38c6152 Change-Id: I33a116e5b13325a6dd5fe27d6dfe87764ffd6a3a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117781 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent f057e25 commit b43bb45

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

runtime/vm/compiler/jit/compiler.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,18 +647,15 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
647647
{
648648
TIMELINE_DURATION(thread(), CompilerVerbose, "FinalizeCompilation");
649649

650-
auto mutator_fun = [&]() {
651-
*result =
652-
FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
653-
};
654-
auto bg_compiler_fun = [&]() {
655-
if (Compiler::IsBackgroundCompilation()) {
656-
CheckIfBackgroundCompilerIsBeingStopped(optimized());
657-
}
650+
auto install_code_fun = [&]() {
658651
*result =
659652
FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
660653
};
661654

655+
if (Compiler::IsBackgroundCompilation()) {
656+
CheckIfBackgroundCompilerIsBeingStopped(optimized());
657+
}
658+
662659
// We have to ensure no mutators are running, because:
663660
//
664661
// a) We allocate an instructions object, which might cause us to
@@ -673,7 +670,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
673670
// those writes are observed atomically.
674671
//
675672
thread()->isolate_group()->RunWithStoppedMutators(
676-
mutator_fun, bg_compiler_fun, /*use_force_growth=*/true);
673+
install_code_fun, install_code_fun, /*use_force_growth=*/true);
677674

678675
// We notify code observers after finalizing the code in order to be
679676
// outside a [SafepointOperationScope].

0 commit comments

Comments
 (0)