Skip to content

[Flutter GPU] FlutterGpuCommandBufferTest aborts in debug builds: CommandBuffer is created on the stack #194149

Open

Description

@dzolotov

Problem

The three tests in lib/gpu/command_buffer_unittests.cc (FlutterGpuCommandBufferTest.*) abort in an unoptimized debug build:

[ RUN      ] FlutterGpuCommandBufferTest.RejectsCompletionCallbacksAfterSubmit
[FATAL:flutter/fml/memory/ref_counted_internal.h(97)] Check failed: !adoption_required_.
[ERROR:flutter/fml/backtrace.cc(108)] Caught signal SIGABRT during program execution.
...
Frame 4: fml::internal::RefCountedThreadSafeBase::~RefCountedThreadSafeBase()

Each test builds the flutter::gpu::CommandBuffer on the stack:

CommandBuffer command_buffer(context, impeller_command_buffer);

CommandBuffer is ref-counted, and an fml ref-counted object has to be adopted (created through fml::MakeRefCounted) before it is destroyed. A stack instance is never adopted, so its destructor trips the debug check. The check is debug-only, which I assume is why CI doesn't see it.

Steps to reproduce

macOS arm64, an existing host_debug_unopt_arm64 build. The test file is the same on current main.

cd engine/src
ninja -C out/host_debug_unopt_arm64 flutter/lib/gpu:gpu_unittests
out/host_debug_unopt_arm64/gpu_unittests --gtest_filter='FlutterGpuCommandBufferTest.*'

All three tests abort as above. The other gpu_unittests suites pass.

Proposed fix

Create the command buffer with fml::MakeRefCounted<CommandBuffer>(...) in the three tests and use it through the returned fml::RefPtr. No engine code changes.

I ran into this while testing a few Flutter GPU fixes locally; until it's fixed I leave FlutterGpuCommandBufferTest.* out of the gpu_unittests filter in those PRs.

Activity

  1. added
    in triagePresently being triaged by the triage team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 12, 2026
  2. puneetkukreja98 commented on Oct 12, 2026

    @puneetkukreja98
    Contributor

    @dzolotov Thanks for reporting this, routing this to team-fluttergpu for further investigation.

  3. niharikavuchintala commented on Oct 12, 2026

    @niharikavuchintala

    hi id like to work on this issue, i noticed that there are currently no branches or PRs linked to this issue, can u assign it to me?? id like to contribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      🤔 Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions