Fix use-after-close for process HANDLE in PerformOSMemoryDump [chromium/src : main]

0 views
Skip to first unread message

Javier Flores Assad (Gerrit)

unread,
Jul 27, 2026, 4:10:58 PM (9 days ago) Jul 27
to Chris Hamilton, Sam Fortiner, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
Attention needed from Chris Hamilton

Javier Flores Assad voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Chris Hamilton
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
Gerrit-Change-Number: 8156120
Gerrit-PatchSet: 1
Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
Gerrit-CC: Sam Fortiner <sam...@microsoft.com>
Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
Gerrit-Comment-Date: Mon, 27 Jul 2026 20:10:48 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Sam Fortiner (Gerrit)

unread,
Jul 27, 2026, 5:36:39 PM (9 days ago) Jul 27
to Javier Flores Assad, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
Attention needed from Chris Hamilton and Javier Flores Assad

Sam Fortiner added 2 comments

Commit Message
Line 7, Patchset 1 (Latest):Fix use-after-close for process HANDLE in PerformOSMemoryDump

There were two issues in the original code:
Real: base::Process::Open(pid) returns a temporary base::Process
(a move-only RAII owner of the handle). .Handle() just borrows the raw
handle. At the semicolon, that temporary base::Process is destroyed.
So the handle is dangling/closed before it's ever used.

Theoretical: The pid could be no longer valid by the time we open a
handle to it. This means that ::Open could fail. But, in practice, this
will not occur because the browser holds open handles to the processes
and closed on the same sequence that services the dump request.
Sam Fortiner . unresolved

The current CL description doesn't appear to capture the full extent of the issue/fix. It discusses the lifetime bug but not the `kNullProcessId` special-casing which also seems important for Windows/Mac. Here's a suggested revision:

There were two issues in the original code:

First, base::Process::Open(pid) returns a temporary base::Process (a
move-only RAII owner of the handle). .Handle() just borrows the raw
handle, which is closed when the temporary is destroyed at the
semicolon leaving FillOSMemoryDump/FillProcessMemoryMaps with an
already-closed handle.

Second, pids can legitimately contain kNullProcessId, meaning "dump my
own process" (common on non-Linux/ChromeOS, see RequestOSMemoryDump's
mojom comment and QueuedRequestDispatcher). Be aware that
base::Process::Open(kNullProcessId) is invalid on every platform, so
this CL special-cases it to base::Process::Current(). Without this, the
new IsValid() check added below would regress self-dumps everywhere
(they already silently failed on Windows).

Note: pid-not-found failures now correctly report kProcessNotFound
instead of kFillOsMemoryDumpFailed, shifting counts between these two
UMA buckets. No other behavior change.

File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc
Line 190, Patchset 1 (Latest):void ClientProcessImpl::PerformOSMemoryDump(OSMemoryDumpArgs args) {
Sam Fortiner . unresolved

This seems like a legitimate test gap. Can we add a new client_process_impl_unittest.cc that calls RequestOSMemoryDump on a real ClientProcessImpl for two cases: `pids = {base::kNullProcessId}` (the "dump my own process" used on non-Linux/ChromeOS) and `pids = {base::Process::Current().Pid()}` (the real-pid path Linux uses), asserting `outcome == kSuccess` and that the returned dump has sane, non-default fields (e.g. non-zero resident set). Use `mojom::MemoryMapOption::NONE` with no extra `MemDumpFlags` to keep it to real but cheap syscalls (avoid MODULES/FULL).

Open in Gerrit

Related details

Attention is currently required from:
  • Chris Hamilton
  • Javier Flores Assad
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
    Gerrit-Change-Number: 8156120
    Gerrit-PatchSet: 1
    Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
    Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
    Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
    Gerrit-CC: Sam Fortiner <sam...@microsoft.com>
    Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
    Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
    Gerrit-Comment-Date: Mon, 27 Jul 2026 21:36:28 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Javier Flores Assad (Gerrit)

    unread,
    Jul 27, 2026, 5:51:52 PM (9 days ago) Jul 27
    to Chris Hamilton, Sam Fortiner, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
    Attention needed from Chris Hamilton and Sam Fortiner

    Javier Flores Assad added 2 comments

    Patchset-level comments
    File-level comment, Patchset 2 (Latest):
    Javier Flores Assad . resolved

    Fixed description, will add test.

    Commit Message
    Line 7, Patchset 1:Fix use-after-close for process HANDLE in PerformOSMemoryDump


    There were two issues in the original code:
    Real: base::Process::Open(pid) returns a temporary base::Process
    (a move-only RAII owner of the handle). .Handle() just borrows the raw
    handle. At the semicolon, that temporary base::Process is destroyed.
    So the handle is dangling/closed before it's ever used.

    Theoretical: The pid could be no longer valid by the time we open a
    handle to it. This means that ::Open could fail. But, in practice, this
    will not occur because the browser holds open handles to the processes
    and closed on the same sequence that services the dump request.
    Sam Fortiner . resolved

    The current CL description doesn't appear to capture the full extent of the issue/fix. It discusses the lifetime bug but not the `kNullProcessId` special-casing which also seems important for Windows/Mac. Here's a suggested revision:

    There were two issues in the original code:

    First, base::Process::Open(pid) returns a temporary base::Process (a
    move-only RAII owner of the handle). .Handle() just borrows the raw
    handle, which is closed when the temporary is destroyed at the
    semicolon leaving FillOSMemoryDump/FillProcessMemoryMaps with an
    already-closed handle.

    Second, pids can legitimately contain kNullProcessId, meaning "dump my
    own process" (common on non-Linux/ChromeOS, see RequestOSMemoryDump's
    mojom comment and QueuedRequestDispatcher). Be aware that
    base::Process::Open(kNullProcessId) is invalid on every platform, so
    this CL special-cases it to base::Process::Current(). Without this, the
    new IsValid() check added below would regress self-dumps everywhere
    (they already silently failed on Windows).

    Note: pid-not-found failures now correctly report kProcessNotFound
    instead of kFillOsMemoryDumpFailed, shifting counts between these two
    UMA buckets. No other behavior change.

    Javier Flores Assad

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Chris Hamilton
    • Sam Fortiner
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
    Gerrit-Change-Number: 8156120
    Gerrit-PatchSet: 2
    Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
    Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
    Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
    Gerrit-CC: Sam Fortiner <sam...@microsoft.com>
    Gerrit-Attention: Sam Fortiner <sam...@microsoft.com>
    Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
    Gerrit-Comment-Date: Mon, 27 Jul 2026 21:51:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Sam Fortiner <sam...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Javier Flores Assad (Gerrit)

    unread,
    Jul 27, 2026, 7:55:23 PM (9 days ago) Jul 27
    to Chris Hamilton, Sam Fortiner, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
    Attention needed from Chris Hamilton and Sam Fortiner

    Javier Flores Assad added 2 comments

    Javier Flores Assad . resolved

    Thanks for your suggestion. Specific tests added.

    File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc
    Line 190, Patchset 1:void ClientProcessImpl::PerformOSMemoryDump(OSMemoryDumpArgs args) {
    Sam Fortiner . resolved

    This seems like a legitimate test gap. Can we add a new client_process_impl_unittest.cc that calls RequestOSMemoryDump on a real ClientProcessImpl for two cases: `pids = {base::kNullProcessId}` (the "dump my own process" used on non-Linux/ChromeOS) and `pids = {base::Process::Current().Pid()}` (the real-pid path Linux uses), asserting `outcome == kSuccess` and that the returned dump has sane, non-default fields (e.g. non-zero resident set). Use `mojom::MemoryMapOption::NONE` with no extra `MemDumpFlags` to keep it to real but cheap syscalls (avoid MODULES/FULL).

    Javier Flores Assad

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Chris Hamilton
    • Sam Fortiner
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
      Gerrit-Change-Number: 8156120
      Gerrit-PatchSet: 3
      Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
      Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
      Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
      Gerrit-CC: Sam Fortiner <sam...@microsoft.com>
      Gerrit-Attention: Sam Fortiner <sam...@microsoft.com>
      Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
      Gerrit-Comment-Date: Mon, 27 Jul 2026 23:55:13 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Sam Fortiner (Gerrit)

      unread,
      Jul 27, 2026, 8:37:35 PM (9 days ago) Jul 27
      to Javier Flores Assad, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
      Attention needed from Chris Hamilton and Javier Flores Assad

      Sam Fortiner voted and added 3 comments

      Votes added by Sam Fortiner

      Code-Review+1

      3 comments

      Patchset-level comments
      Sam Fortiner . resolved

      Thanks for adding the test!

      File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
      Line 76, Patchset 3 (Latest): mojom::RequestOutcome RequestOSMemoryDumpAndWait(
      Sam Fortiner . unresolved

      Not blocking for me, but I noticed that `MemoryTracingIntegrationTest` has similar tests. chrisha@ may have an opinion about if we should add these tests here, in this new test fixture, vs add a test to `MemoryTracingIntegrationTest` instead that covers the same things.

      Line 83, Patchset 3 (Latest): auto result = future.Take();
      if (dumps) {
      *dumps = std::move(std::get<1>(result));
      }
      return std::get<0>(result);
      Sam Fortiner . unresolved

      This can be rewritten as follows I believe:

      ```suggestion
      auto result = future.Take();
      if (dumps) {
      *dumps = std::move(std::get<RawOSMemDumpMap>(result));
      }
      return std::get<mojom::RequestOutcome>(result);
      ```
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Chris Hamilton
      • Javier Flores Assad
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
        Gerrit-Change-Number: 8156120
        Gerrit-PatchSet: 3
        Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
        Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
        Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
        Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
        Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
        Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
        Gerrit-Comment-Date: Tue, 28 Jul 2026 00:37:25 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Javier Flores Assad (Gerrit)

        unread,
        Jul 28, 2026, 12:28:23 AM (9 days ago) Jul 28
        to Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
        Attention needed from Chris Hamilton and Sam Fortiner

        Javier Flores Assad added 3 comments

        Javier Flores Assad . resolved

        Decided to keep the UTs in separate files, reason on reply to comment.
        Changed the getters to use types instead of indexes (good call)

        File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
        Line 76, Patchset 3: mojom::RequestOutcome RequestOSMemoryDumpAndWait(
        Sam Fortiner . resolved

        Not blocking for me, but I noticed that `MemoryTracingIntegrationTest` has similar tests. chrisha@ may have an opinion about if we should add these tests here, in this new test fixture, vs add a test to `MemoryTracingIntegrationTest` instead that covers the same things.

        Javier Flores Assad

        Similar, but I prefer to have UTs match the file/class they test.

        •  tracing_integration_unittest.cc — MemoryTracingIntegrationTest , uses a  MockCoordinator , and tests the memory-infra tracing path:  RequestChromeMemoryDump , periodic dumps, trace configs, allowlisting. It does not test  RequestOSMemoryDump  at all.
        •  client_process_impl_unittest.cc  ClientProcessImplTest , no coordinator, tests the OS memory dump path ( RequestOSMemoryDump ) against a real process. The only overlap with the existing file is SetUp boilerplate (tracing env + MDM), not the behavior under test.

        I recommend we keep them separate.

        Line 83, Patchset 3: auto result = future.Take();

        if (dumps) {
        *dumps = std::move(std::get<1>(result));
        }
        return std::get<0>(result);
        Sam Fortiner . resolved

        This can be rewritten as follows I believe:

        ```suggestion
        auto result = future.Take();
        if (dumps) {
        *dumps = std::move(std::get<RawOSMemDumpMap>(result));
        }
        return std::get<mojom::RequestOutcome>(result);
        ```
        Javier Flores Assad

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Chris Hamilton
        • Sam Fortiner
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
          Gerrit-Change-Number: 8156120
          Gerrit-PatchSet: 4
          Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
          Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
          Gerrit-Attention: Sam Fortiner <sam...@microsoft.com>
          Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
          Gerrit-Comment-Date: Tue, 28 Jul 2026 04:28:11 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sam Fortiner (Gerrit)

          unread,
          Jul 28, 2026, 2:57:37 PM (8 days ago) Jul 28
          to Javier Flores Assad, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
          Attention needed from Chris Hamilton, Javier Flores Assad and Joe Mason

          Sam Fortiner voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Chris Hamilton
          • Javier Flores Assad
          • Joe Mason
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
          Gerrit-Change-Number: 8156120
          Gerrit-PatchSet: 4
          Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
          Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Joe Mason <joenot...@google.com>
          Gerrit-Attention: Joe Mason <joenot...@google.com>
          Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
          Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Comment-Date: Tue, 28 Jul 2026 18:57:27 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Joe Mason (Gerrit)

          unread,
          Jul 28, 2026, 5:59:47 PM (8 days ago) Jul 28
          to Javier Flores Assad, Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
          Attention needed from Chris Hamilton and Javier Flores Assad

          Joe Mason voted and added 7 comments

          Votes added by Joe Mason

          Code-Review+1

          7 comments

          Patchset-level comments
          Joe Mason . resolved

          Thanks a lot for the fix!

          File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
          Line 31, Patchset 4 (Latest):using RawOSMemDumpMap = base::flat_map<base::ProcessId, mojom::RawOSMemDumpPtr>;
          Joe Mason . resolved

          Optional nit: the current advice in https://chromium.googlesource.com/chromium/src/+/main/base/containers/README.md says to use `absl::flat_hash_map` by default because it has better general performance characteristics.

          Not a big deal for the test, just evangelizing.

          EDIT: nevermind, I see that's an alias for an existing map type. I'll leave the evangelizing here since I spent all that time on it.

          Line 46, Patchset 4 (Latest): base::SingleThreadTaskRunner::GetCurrentDefault());
          Joe Mason . unresolved

          Nit: prefer `task_environment_.GetMainThreadTaskRunner()`. It's cleaner.

          Line 57, Patchset 4 (Latest): mojo::PendingRemote<mojom::ClientProcess> process;
          Joe Mason . unresolved

          Nit: this could use a comment saying we don't need the PendingRemote because we call the overridden methods on `client_process_` directly. I was a bit confused about why it was allowed to go out of scope until I realized that.

          Line 60, Patchset 4 (Latest): client_process_.reset(new ClientProcessImpl(
          Joe Mason . unresolved

          Nit: prefer `child_process_ = base::WrapUnique(new ...)`, which is a keyword that can more easily be audited for misuse.

          Line 67, Patchset 4 (Latest): client_process_.reset();
          Joe Mason . unresolved

          Optional nit: https://google.github.io/googletest/faq.html#CtorVsSetUp recommends only using SetUp / TearDown if there's setup code that can't run in the constructor / destructor. (eg. calls to ASSERT_xx). In this case if you use the constructor instead of SetUp(), the destructor wouldn't have to remember to clear any of these, it can just call `ResetForTesting`.

          (And I believe TracingEnvironment wouldn't need to be a unique_ptr, since you wouldn't need to reset it before the destructor.)

          Line 93, Patchset 4 (Latest): raw_ptr<base::trace_event::MemoryDumpManager> mdm_ = nullptr;
          Joe Mason . unresolved

          Optional nit: this isn't needed. You could just call `GetInstance()->ResetForTesting()` in teardown.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Chris Hamilton
          • Javier Flores Assad
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
          Gerrit-Change-Number: 8156120
          Gerrit-PatchSet: 4
          Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
          Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Reviewer: Joe Mason <joenot...@google.com>
          Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
          Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
          Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
          Gerrit-Comment-Date: Tue, 28 Jul 2026 21:59:34 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Joe Mason (Gerrit)

          unread,
          Jul 28, 2026, 6:02:45 PM (8 days ago) Jul 28
          to Javier Flores Assad, Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
          Attention needed from Chris Hamilton and Javier Flores Assad

          Joe Mason added 1 comment

          File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
          Line 76, Patchset 3: mojom::RequestOutcome RequestOSMemoryDumpAndWait(
          Sam Fortiner . resolved

          Not blocking for me, but I noticed that `MemoryTracingIntegrationTest` has similar tests. chrisha@ may have an opinion about if we should add these tests here, in this new test fixture, vs add a test to `MemoryTracingIntegrationTest` instead that covers the same things.

          Javier Flores Assad

          Similar, but I prefer to have UTs match the file/class they test.

          •  tracing_integration_unittest.cc — MemoryTracingIntegrationTest , uses a  MockCoordinator , and tests the memory-infra tracing path:  RequestChromeMemoryDump , periodic dumps, trace configs, allowlisting. It does not test  RequestOSMemoryDump  at all.
          •  client_process_impl_unittest.cc  ClientProcessImplTest , no coordinator, tests the OS memory dump path ( RequestOSMemoryDump ) against a real process. The only overlap with the existing file is SetUp boilerplate (tracing env + MDM), not the behavior under test.

          I recommend we keep them separate.

          Joe Mason

          Agreed.

          chrisha@ no longer works on Chrome, BTW. (He's still at Google but moved to a different project several years ago.)

          Gerrit-Comment-Date: Tue, 28 Jul 2026 22:02:35 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Sam Fortiner <sam...@microsoft.com>
          Comment-In-Reply-To: Javier Flores Assad <flo...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Javier Flores Assad (Gerrit)

          unread,
          Jul 29, 2026, 2:17:56 PM (7 days ago) Jul 29
          to Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
          Attention needed from Chris Hamilton, Joe Mason and Sam Fortiner

          Javier Flores Assad added 6 comments

          Javier Flores Assad . resolved

          Thank you for the review Joe, comments addressed.

          File services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
          Line 46, Patchset 4: base::SingleThreadTaskRunner::GetCurrentDefault());
          Joe Mason . resolved

          Nit: prefer `task_environment_.GetMainThreadTaskRunner()`. It's cleaner.

          Javier Flores Assad

          Done

          Line 57, Patchset 4: mojo::PendingRemote<mojom::ClientProcess> process;
          Joe Mason . resolved

          Nit: this could use a comment saying we don't need the PendingRemote because we call the overridden methods on `client_process_` directly. I was a bit confused about why it was allowed to go out of scope until I realized that.

          Javier Flores Assad

          Done

          Line 60, Patchset 4: client_process_.reset(new ClientProcessImpl(
          Joe Mason . resolved

          Nit: prefer `child_process_ = base::WrapUnique(new ...)`, which is a keyword that can more easily be audited for misuse.

          Javier Flores Assad

          Done

          Line 67, Patchset 4: client_process_.reset();
          Joe Mason . resolved

          Optional nit: https://google.github.io/googletest/faq.html#CtorVsSetUp recommends only using SetUp / TearDown if there's setup code that can't run in the constructor / destructor. (eg. calls to ASSERT_xx). In this case if you use the constructor instead of SetUp(), the destructor wouldn't have to remember to clear any of these, it can just call `ResetForTesting`.

          (And I believe TracingEnvironment wouldn't need to be a unique_ptr, since you wouldn't need to reset it before the destructor.)

          Javier Flores Assad

          Done

          Line 93, Patchset 4: raw_ptr<base::trace_event::MemoryDumpManager> mdm_ = nullptr;
          Joe Mason . resolved

          Optional nit: this isn't needed. You could just call `GetInstance()->ResetForTesting()` in teardown.

          Javier Flores Assad

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Chris Hamilton
          • Joe Mason
          • Sam Fortiner
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
            Gerrit-Change-Number: 8156120
            Gerrit-PatchSet: 5
            Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
            Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Joe Mason <joenot...@google.com>
            Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
            Gerrit-Attention: Sam Fortiner <sam...@microsoft.com>
            Gerrit-Attention: Joe Mason <joenot...@google.com>
            Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
            Gerrit-Comment-Date: Wed, 29 Jul 2026 18:17:45 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Joe Mason <joenot...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Sam Fortiner (Gerrit)

            unread,
            Jul 29, 2026, 5:15:21 PM (7 days ago) Jul 29
            to Javier Flores Assad, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
            Attention needed from Chris Hamilton, Javier Flores Assad and Joe Mason

            Sam Fortiner voted Code-Review+1

            Code-Review+1
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Chris Hamilton
            • Javier Flores Assad
            • Joe Mason
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
            Gerrit-Change-Number: 8156120
            Gerrit-PatchSet: 5
            Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
            Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Joe Mason <joenot...@google.com>
            Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
            Gerrit-Attention: Joe Mason <joenot...@google.com>
            Gerrit-Attention: Chris Hamilton <chr...@chromium.org>
            Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Comment-Date: Wed, 29 Jul 2026 21:15:05 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Javier Flores Assad (Gerrit)

            unread,
            Jul 29, 2026, 5:28:26 PM (7 days ago) Jul 29
            to Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
            Attention needed from Joe Mason

            Javier Flores Assad added 1 comment

            Patchset-level comments
            Javier Flores Assad . resolved

            All feedback addressed.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Joe Mason
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
            Gerrit-Change-Number: 8156120
            Gerrit-PatchSet: 5
            Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
            Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
            Gerrit-Reviewer: Joe Mason <joenot...@google.com>
            Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
            Gerrit-Attention: Joe Mason <joenot...@google.com>
            Gerrit-Comment-Date: Wed, 29 Jul 2026 21:28:14 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Joe Mason (Gerrit)

            unread,
            Jul 29, 2026, 5:33:30 PM (7 days ago) Jul 29
            to Javier Flores Assad, Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org
            Attention needed from Javier Flores Assad

            Joe Mason voted Code-Review+1

            Code-Review+1
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Javier Flores Assad
            Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement satisfiedCode-Owners
              • requirement satisfiedCode-Review
              • requirement satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
              Gerrit-Change-Number: 8156120
              Gerrit-PatchSet: 5
              Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
              Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Joe Mason <joenot...@google.com>
              Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
              Gerrit-Attention: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Comment-Date: Wed, 29 Jul 2026 21:33:22 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              satisfied_requirement
              open
              diffy

              Javier Flores Assad (Gerrit)

              unread,
              Jul 29, 2026, 5:38:49 PM (7 days ago) Jul 29
              to Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org

              Javier Flores Assad voted Commit-Queue+2

              Commit-Queue+2
              Open in Gerrit

              Related details

              Attention set is empty
              Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement satisfiedCode-Owners
              • requirement satisfiedCode-Review
              • requirement satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
              Gerrit-Change-Number: 8156120
              Gerrit-PatchSet: 5
              Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
              Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Joe Mason <joenot...@google.com>
              Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
              Gerrit-Comment-Date: Wed, 29 Jul 2026 21:38:36 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              satisfied_requirement
              open
              diffy

              Chromium LUCI CQ (Gerrit)

              unread,
              Jul 29, 2026, 5:57:50 PM (7 days ago) Jul 29
              to Javier Flores Assad, Sam Fortiner, Chris Hamilton, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, chrome-gr...@chromium.org

              Chromium LUCI CQ submitted the change

              Change information

              Commit message:
              Fix use-after-close for process HANDLE in PerformOSMemoryDump

              There were two issues in the original code:

              First, base::Process::Open(pid) returns a temporary base::Process (a
              move-only RAII owner of the handle). .Handle() just borrows the raw
              handle, which is closed when the temporary is destroyed at the semicolon
              leaving FillOSMemoryDump/FillProcessMemoryMaps with an already-closed
              handle.

              Second, pids can legitimately contain kNullProcessId, meaning "dump my
              own process" (common on non-Linux/ChromeOS, see RequestOSMemoryDump's
              mojom comment and QueuedRequestDispatcher). Be aware that
              base::Process::Open(kNullProcessId) is invalid on every platform, so
              this CL special-cases it to base::Process::Current(). Without this, the
              new IsValid() check added below would regress self-dumps everywhere
              (they already silently failed on Windows).

              Note: pid-not-found failures now correctly report kProcessNotFound
              instead of kFillOsMemoryDumpFailed, shifting counts between these two
              UMA buckets. No other behavior change.
              Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
              Reviewed-by: Joe Mason <joenot...@google.com>
              Reviewed-by: Sam Fortiner <sam...@microsoft.com>
              Commit-Queue: Javier Flores Assad <flo...@microsoft.com>
              Cr-Commit-Position: refs/heads/main@{#1670620}
              Files:
              • M services/resource_coordinator/BUILD.gn
              • M services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc
              • M services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.h
              • A services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl_unittest.cc
              Change size: M
              Delta: 4 files changed, 150 insertions(+), 5 deletions(-)
              Branch: refs/heads/main
              Submit Requirements:
              • requirement satisfiedCode-Review: +1 by Joe Mason, +1 by Sam Fortiner
              Open in Gerrit
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: merged
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: I5cfffeab4b096301784b9abe10914122540b01ce
              Gerrit-Change-Number: 8156120
              Gerrit-PatchSet: 6
              Gerrit-Owner: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Chris Hamilton <chr...@chromium.org>
              Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
              Gerrit-Reviewer: Javier Flores Assad <flo...@microsoft.com>
              Gerrit-Reviewer: Joe Mason <joenot...@google.com>
              Gerrit-Reviewer: Sam Fortiner <sam...@microsoft.com>
              open
              diffy
              satisfied_requirement
              Reply all
              Reply to author
              Forward
              0 new messages