Fix MultiplexRouter Lifetime Management during error handling [chromium/src : main]

1 view
Skip to first unread message

Emily Andrews (Gerrit)

unread,
Nov 17, 2025, 9:34:11 PM11/17/25
to Daniel Cheng, chromium...@chromium.org
Attention needed from Daniel Cheng

Emily Andrews added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Emily Andrews . resolved

Hey Daniel!

I was able to reproduce the MultiplexRouter lifetime issue via test code and some synchonization games, so I figured I'd put up a CL and we'd be able to get it in for Christmas!

I suspect this could be causing some of the heap corruption we've been seeing in Mojo. This sort of thing would be a hotpath.

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
Gerrit-Change-Number: 7164260
Gerrit-PatchSet: 1
Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Tue, 18 Nov 2025 02:34:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Cheng (Gerrit)

unread,
Nov 18, 2025, 12:12:51 PM11/18/25
to Emily Andrews, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
Attention needed from Emily Andrews and Stefan Smolen

Daniel Cheng added 6 comments

File mojo/public/cpp/bindings/connector.h
Line 317, Patchset 2 (Latest): base::OnceClosure error_handler_called_for_testing_;
Daniel Cheng . unresolved

I am really not a fan of test-only callbacks. Is this something we'll need forever? Are there any possible alternatives?

File mojo/public/cpp/bindings/lib/multiplex_router.cc
Line 440, Patchset 2 (Latest): &MultiplexRouter::OnPipeConnectionError, base::WrapRefCounted(this),
Daniel Cheng . unresolved

I think this needs a comment to explain why it won't be a leak, since it looks like `this` owns `connector_`.

Is it important to add this ref preemptively? We can't just `scoped_refptr protect(this);` in `OnPipeConnectionError()`?

Based on the CL description, it sounds like it wouldn't work because the error handler callback is posted, and so the ref needs to exist while the callback is in flight, but more comments would be good.

File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
Line 522, Patchset 2 (Latest): // Without the extra reference from
Daniel Cheng . unresolved

It looks like the extra reference causes the WeakPtrFactory to be invalidated on the wrong thread sometimes:

```
[273332:273343:FATAL:base/memory/weak_ptr.cc:27] DCHECK failed: sequence_checker_.CalledOnValidSequence(&bound_at) || HasOneRef(). WeakPtrs must be invalidated on the same sequenced thread as where they are bound.
Check failed at:
#0 0x60f235f15466 in ___interceptor_backtrace ??:0:0
#1 0x60f23c1ad548 in base::debug::CollectStackTrace(base::span<void const*, 18446744073709551615ul, void const**>) ./../../base/debug/stack_trace_posix.cc:1052:7
#2 0x60f23c17e81f in base::debug::StackTrace::StackTrace(unsigned long) ./../../base/debug/stack_trace.cc:279:20
#3 0x60f23be973c5 in logging::LogMessage::Flush() ./../../base/logging.cc:705:29
#4 0x60f23be96f30 in logging::LogMessage::~LogMessage() ./../../base/logging.cc:694:3
#5 0x60f23be63dc1 in ~DCheckLogMessage ./../../base/check.cc:147:3
#6 0x60f23be63dc1 in logging::(anonymous namespace)::DCheckLogMessage::~DCheckLogMessage() ./../../base/check.cc:143:32
#7 0x60f23be62c30 in operator() ./gen/third_party/libc++/src/include/__memory/unique_ptr.h:77:5
#8 0x60f23be62c30 in reset ./gen/third_party/libc++/src/include/__memory/unique_ptr.h:290:7
#9 0x60f23be62c30 in logging::NotReachedError::~NotReachedError() ./../../base/check.cc:306:16
#10 0x60f23beb6140 in base::internal::WeakReference::Flag::Invalidate() ./../../base/memory/weak_ptr.cc:27:3
#11 0x60f23beb70a6 in base::internal::WeakReferenceOwner::~WeakReferenceOwner() ./../../base/memory/weak_ptr.cc:87:12
#12 0x60f23e3c5d69 in mojo::Connector::~Connector() ./../../mojo/public/cpp/bindings/lib/connector.cc:177:1
#13 0x60f23e40257d in mojo::internal::MultiplexRouter::~MultiplexRouter() ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:468:1
#14 0x60f2369f7d0c in ~TestableMultiplexRouter ./../../mojo/public/cpp/bindings/tests/testable_multiplex_router.cc:56:1
#15 0x60f2369f7d0c in ~TestableMultiplexRouter ./../../mojo/public/cpp/bindings/tests/testable_multiplex_router.cc:52:53
#16 0x60f2369f7d0c in non-virtual thunk to mojo::test::TestableMultiplexRouter::~TestableMultiplexRouter() ./../../mojo/public/cpp/bindings/tests/testable_multiplex_router.cc:0:0
#17 0x60f2369f87e8 in DeleteInternal<mojo::AssociatedGroupController> ./../../base/memory/ref_counted.h:438:5
#18 0x60f2369f87e8 in Destruct ./../../base/memory/ref_counted.h:391:5
#19 0x60f2369f87e8 in Release ./../../base/memory/ref_counted.h:427:7
#20 0x60f2369f87e8 in Release ./../../base/memory/scoped_refptr.h:392:8
#21 0x60f2369f87e8 in ~scoped_refptr ./../../base/memory/scoped_refptr.h:280:7
#22 0x60f2369f87e8 in reset ./../../base/memory/scoped_refptr.h:311:18
#23 0x60f2369f87e8 in mojo::test::TestableMultiplexRouter::Scheduler::ResetRouter() ./../../mojo/public/cpp/bindings/tests/testable_multiplex_router.cc:83:11
#24 0x60f2369f9202 in Invoke<void (mojo::test::TestableMultiplexRouter::Scheduler::*)(), mojo::test::TestableMultiplexRouter::Scheduler *> ./../../base/functional/bind_internal.h:730:12
#25 0x60f2369f9202 in MakeItSo<void (mojo::test::TestableMultiplexRouter::Scheduler::*)(), std::__Cr::tuple<base::internal::UnretainedWrapper<mojo::test::TestableMultiplexRouter::Scheduler, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0> > > ./../../base/functional/bind_internal.h:922:12
#26 0x60f2369f9202 in RunImpl<void (mojo::test::TestableMultiplexRouter::Scheduler::*)(), std::__Cr::tuple<base::internal::UnretainedWrapper<mojo::test::TestableMultiplexRouter::Scheduler, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0> >, 0UL> ./../../base/functional/bind_internal.h:1059:14
#27 0x60f2369f9202 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::test::TestableMultiplexRouter::Scheduler::*&&)(), mojo::test::TestableMultiplexRouter::Scheduler*>, base::internal::BindState<true, true, false, void (mojo::test::TestableMultiplexRouter::Scheduler::*)(), base::internal::UnretainedWrapper<mojo::test::TestableMultiplexRouter::Scheduler, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:972:12
#28 0x60f235fe2666 in base::OnceCallback<void ()>::Run() && ./../../base/functional/callback.h:155:12
#29 0x60f23bf756b8 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:229:34
#30 0x60f23c022493 in RunTask<(lambda at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:474:11)> ./../../base/task/common/task_annotator.h:113:5
#31 0x60f23c022493 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:472:23
#32 0x60f23c0208ce in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:346:40
#33 0x60f23c1c6f07 in base::MessagePumpEpoll::Run(base::MessagePump::Delegate*) ./../../base/message_loop/message_pump_epoll.cc:224:55
#34 0x60f23c024843 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:647:12
#35 0x60f23bf2c855 in base::RunLoop::Run(base::Location const&) ./../../base/run_loop.cc:134:14
#36 0x60f23c111da3 in base::Thread::Run(base::RunLoop*) ./../../base/threading/thread.cc:361:13
#37 0x60f23c11266a in base::Thread::ThreadMain() ./../../base/threading/thread.cc:436:3
#38 0x60f23c16676f in base::(anonymous namespace)::ThreadFunc(void*) ./../../base/threading/platform_thread_posix.cc:102:13
#39 0x60f235f6d587 in asan_thread_start(void*) _asan_rtl_:0
```
File mojo/public/cpp/bindings/tests/testable_multiplex_router.cc
Line 15, Patchset 2 (Latest):namespace mojo {
Daniel Cheng . unresolved

Please fix this WARNING reported by ClangTidy: check: modernize-concat-nested-namespaces

nested namespaces can be concatenated...

check: modernize-concat-nested-namespaces

nested namespaces can be concatenated (https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html)

(Note: You can add `Skip-Clang-Tidy-Checks: modernize-concat-nested-namespaces` footer to the CL description to skip the check)

(Lint observed on `linux-clang-tidy-rel`, but not on `android-clang-tidy-rel`)

Line 37, Patchset 2 (Latest): auto router = base::WrapRefCounted(new TestableMultiplexRouter(
std::move(message_pipe), config, set_interface_id_namespace_bit, runner,
"TestableMultiplexRouter"));
Daniel Cheng . unresolved
```suggestion
auto router = base::MakeRefCounted<TestableMultiplexRouter>(
std::move(message_pipe), config, set_interface_id_namespace_bit, runner,
"TestableMultiplexRouter");
```
Line 54, Patchset 2 (Latest): destructor_wait_->TimedWait(base::Seconds(1));
Daniel Cheng . unresolved

Why 1 second?

Open in Gerrit

Related details

Attention is currently required from:
  • Emily Andrews
  • Stefan Smolen
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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
    Gerrit-Change-Number: 7164260
    Gerrit-PatchSet: 2
    Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
    Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
    Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
    Gerrit-Comment-Date: Tue, 18 Nov 2025 17:12:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stefan Smolen (Gerrit)

    unread,
    Nov 18, 2025, 1:10:16 PM11/18/25
    to Emily Andrews, Chromium LUCI CQ, Daniel Cheng, chromium...@chromium.org
    Attention needed from Emily Andrews

    Stefan Smolen added 1 comment

    File mojo/public/cpp/bindings/lib/multiplex_router.h
    Line 318, Patchset 1: Connector connector_;
    Stefan Smolen . unresolved

    the connector_ is owned by the MultiplexRouter, so it will be deleted at the same time. Is that not the issue here, that the connector_ and MultiplexRouter are deleted while the Connector is performing the error handling on its own sequence? Does the sequence check hit all the time if we make it prominent in the Connector dtor?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Emily Andrews
    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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
    Gerrit-Change-Number: 7164260
    Gerrit-PatchSet: 2
    Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
    Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
    Gerrit-Comment-Date: Tue, 18 Nov 2025 18:10:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Nov 19, 2025, 12:58:15 PM11/19/25
    to Emily Andrews, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
    Attention needed from Emily Andrews

    Andrea Orru added 1 comment

    File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Emily Andrews
    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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
    Gerrit-Change-Number: 7164260
    Gerrit-PatchSet: 2
    Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
    Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
    Gerrit-CC: Andrea Orru <andre...@chromium.org>
    Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
    Gerrit-Comment-Date: Wed, 19 Nov 2025 17:58:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Emily Andrews (Gerrit)

    unread,
    Nov 21, 2025, 4:48:28 PM11/21/25
    to Andrea Orru, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
    Attention needed from Andrea Orru, Daniel Cheng and Stefan Smolen

    Emily Andrews added 8 comments

    Patchset-level comments
    File-level comment, Patchset 6:
    Emily Andrews . resolved

    I addressed the feedback. I integrated the Deleter code, which I think was a really great suggestion from @Andrea. I think by guaranteeing the deletion happens on the same sequence as all the other calls, we guarantee that the Connector will be shutdown before the calls would come in or we guarantee the calls would happen before the MultiplexRouter is actually deleted. I augmented the being_destructed_ to be a mutable atomic bool and had that set in DeleteOnCorrectSequence and added checks before all the base::WrapRefCounted calls for PostTasks to ensure AddRef won't happen after the destruction has been scheduled.

    I will look at the remote_unittest failures probably tonight, but it seems like the issue is hot so I thought I'd put out what I have now as an update.

    File mojo/public/cpp/bindings/connector.h
    Line 317, Patchset 2: base::OnceClosure error_handler_called_for_testing_;
    Daniel Cheng . resolved

    I am really not a fan of test-only callbacks. Is this something we'll need forever? Are there any possible alternatives?

    Emily Andrews

    I updated to friend class the RaceConditionScheduler and I run the callback there right before I call into the method.

    File mojo/public/cpp/bindings/lib/multiplex_router.h
    Line 318, Patchset 1: Connector connector_;
    Stefan Smolen . resolved

    the connector_ is owned by the MultiplexRouter, so it will be deleted at the same time. Is that not the issue here, that the connector_ and MultiplexRouter are deleted while the Connector is performing the error handling on its own sequence? Does the sequence check hit all the time if we make it prominent in the Connector dtor?

    Emily Andrews

    It's not deleted at *exactly* the same time.

    "For both user-defined or implicitly-defined destructors, after executing the body of the destructor and destroying any automatic objects allocated within the body, the compiler calls the destructors for all non-static non-variant data members of the class, in reverse order of declaration, then it calls the destructors of all direct non-virtual base classes in reverse order of construction (which in turn call the destructors of their members and their base classes, etc), and then, if this object is of most derived class, it calls the destructors of all virtual bases.

    Even when the destructor is called directly (e.g. obj.~Foo();), the return statement in ~Foo() does not return control to the caller immediately: it calls all those member and base destructors first."

    https://www.en.cppreference.com/w/cpp/language/destructor.html

    So ~MultiplexRouter is destroyed, and then the member variables are destroyed one at a time in reverse order, with the task_runner_ being destroyed after the connector_ for example.

    I added a MultiplexRouter::DeleteOnCorrectSequence() that gets called by a Destruct method, and that will ensure the destruction is on the right thread and made being_destructed_ a mutable atomic bool set when that method is called. I followed up with checks on that where there were AddRefs to prevent the Use After Free where we have posted the DeleteOnCorrectSequence but then we call something else that AddRefs and posts additional tasks to be handled after that would be called.

    File mojo/public/cpp/bindings/lib/multiplex_router.cc
    Line 440, Patchset 2: &MultiplexRouter::OnPipeConnectionError, base::WrapRefCounted(this),
    Daniel Cheng . resolved

    I think this needs a comment to explain why it won't be a leak, since it looks like `this` owns `connector_`.

    Is it important to add this ref preemptively? We can't just `scoped_refptr protect(this);` in `OnPipeConnectionError()`?

    Based on the CL description, it sounds like it wouldn't work because the error handler callback is posted, and so the ref needs to exist while the callback is in flight, but more comments would be good.

    Emily Andrews

    Done

    File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
    Line 522, Patchset 2: // Without the extra reference from
    Daniel Cheng . resolved
    Emily Andrews

    This is perfect! Truly the solution could not have been complete without that suggestion!

    File mojo/public/cpp/bindings/tests/testable_multiplex_router.cc
    Line 15, Patchset 2:namespace mojo {
    Daniel Cheng . resolved

    Please fix this WARNING reported by ClangTidy: check: modernize-concat-nested-namespaces

    nested namespaces can be concatenated...

    check: modernize-concat-nested-namespaces

    nested namespaces can be concatenated (https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html)

    (Note: You can add `Skip-Clang-Tidy-Checks: modernize-concat-nested-namespaces` footer to the CL description to skip the check)

    (Lint observed on `linux-clang-tidy-rel`, but not on `android-clang-tidy-rel`)

    Emily Andrews

    Done

    Line 37, Patchset 2: auto router = base::WrapRefCounted(new TestableMultiplexRouter(

    std::move(message_pipe), config, set_interface_id_namespace_bit, runner,
    "TestableMultiplexRouter"));
    Daniel Cheng . resolved
    ```suggestion
    auto router = base::MakeRefCounted<TestableMultiplexRouter>(
    std::move(message_pipe), config, set_interface_id_namespace_bit, runner,
    "TestableMultiplexRouter");
    ```
    Emily Andrews

    Done

    Line 54, Patchset 2: destructor_wait_->TimedWait(base::Seconds(1));
    Daniel Cheng . resolved

    Why 1 second?

    Emily Andrews

    To ensure there's never a hang in the test. I added an EXPECT_TRUE so it would be an error to have the time elapse.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrea Orru
    • Daniel Cheng
    • Stefan Smolen
    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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
      Gerrit-Change-Number: 7164260
      Gerrit-PatchSet: 11
      Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
      Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
      Gerrit-CC: Andrea Orru <andre...@chromium.org>
      Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
      Gerrit-Attention: Andrea Orru <andre...@chromium.org>
      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Fri, 21 Nov 2025 21:48:17 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Stefan Smolen <ssm...@microsoft.com>
      Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
      Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Emily Andrews (Gerrit)

      unread,
      Nov 22, 2025, 5:22:59 PM11/22/25
      to Andrea Orru, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
      Attention needed from Andrea Orru, Daniel Cheng and Stefan Smolen

      Emily Andrews added 1 comment

      Patchset-level comments
      File-level comment, Patchset 12 (Latest):
      Emily Andrews . resolved

      Fixed the remoting_unittests issue and should be good to go in if you guys are pleased with the change.

      I removed the feature key, since ensuring destruction on sequence is safe enough and will not result in hangs.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Andrea Orru
      • Daniel Cheng
      • Stefan Smolen
      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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
      Gerrit-Change-Number: 7164260
      Gerrit-PatchSet: 12
      Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
      Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
      Gerrit-CC: Andrea Orru <andre...@chromium.org>
      Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
      Gerrit-Attention: Andrea Orru <andre...@chromium.org>
      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Sat, 22 Nov 2025 22:22:53 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Daniel Cheng (Gerrit)

      unread,
      Nov 27, 2025, 1:13:22 PM11/27/25
      to Emily Andrews, Andrea Orru, Jiewei Qian, Hu, Ningxin, AyeAye, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
      Attention needed from Andrea Orru, Emily Andrews and Stefan Smolen

      Daniel Cheng added 3 comments

      Commit Message
      Line 44, Patchset 18 (Latest):the RefCountedThreadSafe::DeleteInternal implementation.
      Daniel Cheng . unresolved

      Can the CL description mention why the webnn changes are needed? (Though a number of WebNN tests appear to be broken)

      File mojo/public/cpp/bindings/associated_group_controller.h
      Line 84, Patchset 18 (Latest): // Deletes this object on the correct sequence to protect against
      Daniel Cheng . unresolved

      This comment should explain what "the correct sequence is". That might be better suited as a class-level comment line 24 that explains the threading requirements for the class as a whole; then this can just reference that.

      File mojo/public/cpp/bindings/lib/multiplex_router.cc
      Line 572, Patchset 18 (Latest): if (being_destructed_) {
      Daniel Cheng . unresolved

      I'm wondering if this (and other similar checks) are potentially racy.

      What prevents this from being `false` here, but then being set to `true` before the `PostTask()` call below?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Andrea Orru
      • Emily Andrews
      • Stefan Smolen
      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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
        Gerrit-Change-Number: 7164260
        Gerrit-PatchSet: 18
        Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
        Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
        Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
        Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
        Gerrit-CC: Jiewei Qian <q...@chromium.org>
        Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
        Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
        Gerrit-Attention: Andrea Orru <andre...@chromium.org>
        Gerrit-Comment-Date: Thu, 27 Nov 2025 18:13:10 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Cheng (Gerrit)

        unread,
        Dec 5, 2025, 1:20:32 PM12/5/25
        to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Andrea Orru, Jiewei Qian, Hu, Ningxin, AyeAye, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
        Attention needed from Andrea Orru, Emily Andrews and Stefan Smolen

        Daniel Cheng added 1 comment

        Patchset-level comments
        File-level comment, Patchset 19 (Latest):
        Daniel Cheng . resolved

        Is this ready for a re-review?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrea Orru
        • Emily Andrews
        • Stefan Smolen
        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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
        Gerrit-Change-Number: 7164260
        Gerrit-PatchSet: 19
        Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
        Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
        Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
        Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
        Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
        Gerrit-CC: Jiewei Qian <q...@chromium.org>
        Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-CC: Reilly Grant <rei...@chromium.org>
        Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
        Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
        Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
        Gerrit-Attention: Andrea Orru <andre...@chromium.org>
        Gerrit-Comment-Date: Fri, 05 Dec 2025 18:20:13 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Emily Andrews (Gerrit)

        unread,
        Dec 5, 2025, 2:41:27 PM12/5/25
        to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Andrea Orru, Jiewei Qian, Hu, Ningxin, AyeAye, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
        Attention needed from Andrea Orru, Daniel Cheng and Stefan Smolen

        Emily Andrews added 2 comments

        Patchset-level comments
        Daniel Cheng . resolved

        Is this ready for a re-review?

        Emily Andrews

        Not yet, I think you are right about the race, but I'm thinking through when to get rid of the handler reference explicitly once the InterfaceEndpointClient and InterfaceEndpoint are deconstructed. I think I might have something later today.

        The ASAN test failures are because I need to get the right RunLoop hook to run through the asynchronous deconstruction. That might take a little time too.

        File mojo/public/cpp/bindings/lib/multiplex_router.cc
        Line 572, Patchset 18: if (being_destructed_) {
        Daniel Cheng . unresolved

        I'm wondering if this (and other similar checks) are potentially racy.

        What prevents this from being `false` here, but then being set to `true` before the `PostTask()` call below?

        Emily Andrews

        I found a HasAtLeastOneRef API on RefCountedThreadSafe, and this will not be racy.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrea Orru
        • Daniel Cheng
        • Stefan Smolen
        Gerrit-Attention: Andrea Orru <andre...@chromium.org>
        Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
        Gerrit-Comment-Date: Fri, 05 Dec 2025 19:41:20 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Emily Andrews (Gerrit)

        unread,
        Dec 5, 2025, 2:42:01 PM12/5/25
        to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Andrea Orru, Jiewei Qian, Hu, Ningxin, AyeAye, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
        Attention needed from Andrea Orru, Daniel Cheng and Stefan Smolen

        Emily Andrews added 1 comment

        File mojo/public/cpp/bindings/lib/multiplex_router.cc
        Line 572, Patchset 18: if (being_destructed_) {
        Daniel Cheng . unresolved

        I'm wondering if this (and other similar checks) are potentially racy.

        What prevents this from being `false` here, but then being set to `true` before the `PostTask()` call below?

        Emily Andrews

        I found a HasAtLeastOneRef API on RefCountedThreadSafe, and this will not be racy.

        Emily Andrews

        Actually, still a little racy

        Gerrit-Comment-Date: Fri, 05 Dec 2025 19:41:54 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Emily Andrews <emi...@microsoft.com>
        Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Reilly Grant (Gerrit)

        unread,
        Dec 5, 2025, 9:14:58 PM12/5/25
        to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Andrea Orru, Jiewei Qian, Hu, Ningxin, AyeAye, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org
        Attention needed from Andrea Orru, Daniel Cheng, Emily Andrews and Stefan Smolen

        Reilly Grant added 2 comments

        Commit Message
        Line 44, Patchset 18:the RefCountedThreadSafe::DeleteInternal implementation.
        Daniel Cheng . unresolved

        Can the CL description mention why the webnn changes are needed? (Though a number of WebNN tests appear to be broken)

        Reilly Grant

        I'm not surprised the WebNN tests need modifications. We've been struggling in WebNN to ensure that all the impl objects are destroyed during test shutdown because tasks need to be posted between threads.

        File services/webnn/webnn_context_provider_impl.cc
        Line 156, Patchset 19 (Latest):void WebNNContextProviderImpl::SetDisconnectHandlerForTesting( // IN-TEST
        Reilly Grant . unresolved

        Is this comment necessary since the method is named "ForTesting"?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrea Orru
        • Daniel Cheng
        • Emily Andrews
        • Stefan Smolen
        Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
        Gerrit-Attention: Andrea Orru <andre...@chromium.org>
        Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
        Gerrit-Comment-Date: Sat, 06 Dec 2025 02:14:45 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Emily Andrews (Gerrit)

        unread,
        Apr 21, 2026, 12:20:43 PMApr 21
        to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
        Attention needed from Daniel Cheng, Reilly Grant and Stefan Smolen

        Emily Andrews added 5 comments

        Patchset-level comments
        File-level comment, Patchset 39 (Latest):
        Emily Andrews . resolved

        I think I have it now. What I ended up creating was a way for the multiplex router to try to increment itself before it executes code which may be racing during channel shutdown. If it's at a ref count of 0, we just return false and then no-op then early return. I went through and added this check on all the pieces of code and we have a feature flag to turn this on and off. I have put it enabled by default though.

        Commit Message
        Line 44, Patchset 18:the RefCountedThreadSafe::DeleteInternal implementation.
        Daniel Cheng . resolved

        Can the CL description mention why the webnn changes are needed? (Though a number of WebNN tests appear to be broken)

        Reilly Grant

        I'm not surprised the WebNN tests need modifications. We've been struggling in WebNN to ensure that all the impl objects are destroyed during test shutdown because tasks need to be posted between threads.

        Emily Andrews

        I'm moving the WebNN test fixes to a separate CL to reduce the complexity of this one.

        File mojo/public/cpp/bindings/associated_group_controller.h
        Line 84, Patchset 18: // Deletes this object on the correct sequence to protect against
        Daniel Cheng . resolved

        This comment should explain what "the correct sequence is". That might be better suited as a class-level comment line 24 that explains the threading requirements for the class as a whole; then this can just reference that.

        Emily Andrews

        Done

        File mojo/public/cpp/bindings/lib/multiplex_router.cc
        Line 572, Patchset 18: if (being_destructed_) {
        Daniel Cheng . resolved

        I'm wondering if this (and other similar checks) are potentially racy.

        What prevents this from being `false` here, but then being set to `true` before the `PostTask()` call below?

        Emily Andrews

        I found a HasAtLeastOneRef API on RefCountedThreadSafe, and this will not be racy.

        Emily Andrews

        Actually, still a little racy

        Emily Andrews

        Done

        File services/webnn/webnn_context_provider_impl.cc
        Line 156, Patchset 19:void WebNNContextProviderImpl::SetDisconnectHandlerForTesting( // IN-TEST
        Reilly Grant . resolved

        Is this comment necessary since the method is named "ForTesting"?

        Emily Andrews

        The robot was crying at me 😭

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Daniel Cheng
        • Reilly Grant
        • Stefan Smolen
        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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
          Gerrit-Change-Number: 7164260
          Gerrit-PatchSet: 39
          Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
          Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
          Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
          Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
          Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
          Gerrit-CC: Jiewei Qian <q...@chromium.org>
          Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
          Gerrit-CC: Reilly Grant <rei...@chromium.org>
          Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
          Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
          Gerrit-Comment-Date: Tue, 21 Apr 2026 16:20:34 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Daniel Cheng (Gerrit)

          unread,
          Apr 22, 2026, 2:58:37 PMApr 22
          to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
          Attention needed from Emily Andrews, Reilly Grant and Stefan Smolen

          Daniel Cheng added 8 comments

          Patchset-level comments
          Daniel Cheng . resolved

          Some initial thoughts. I haven't looked at the tests yet.

          File ipc/ipc_mojo_bootstrap.cc
          Line 198, Patchset 39 (Latest): delete this;
          Daniel Cheng . unresolved

          Let's explain why `delete this` unconditionally is safe here, i.e. what precondition guarantees that this is safe.

          File mojo/public/cpp/bindings/connector.h
          Line 260, Patchset 39 (Latest): base::WeakPtr<Connector> GetWeakPtrForTesting() {
          Daniel Cheng . unresolved

          Fine to make this public (especially if that avoids the need for a `friend`)

          File mojo/public/cpp/bindings/lib/multiplex_router.h
          Line 156, Patchset 39 (Latest): void DeleteOnCorrectSequence() const override;
          Daniel Cheng . unresolved

          Nit: group this with the other AGC methods

          File mojo/public/cpp/bindings/lib/multiplex_router.cc
          Line 45, Patchset 39 (Latest):// This performs 3 atomic operations (TryAddRef + AddRef + Release) because
          // scoped_refptr has no public constructor that adopts an existing ref without
          // calling AddRef. The private AdoptRefTag constructor is restricted to
          // AdoptRef(), which requires REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE and
          // HasOneRef() — neither of which hold here.
          Daniel Cheng . unresolved

          I think we can extend `scoped_refptr`'s API/helpers to support this so we don't need the extra refcount churn.

          I don't have a good name for this though; to be honest, it is really bizarre to pass around a `T*` to which the refcount is zero, because if the refcount is zero, the object is at best partially valid...

          Line 662, Patchset 39 (Latest): auto prevent_destroy = TryMakeScopedRefPtr(this);
          Daniel Cheng . unresolved

          Can we add a comment here? Presumably the destructor is potentially already on the stack here, but we can explain what scenario this could happen in.

          Line 718, Patchset 39 (Latest): auto prevent_destroy = TryMakeScopedRefPtr(this);
          Daniel Cheng . unresolved

          Same comment here.

          Line 1005, Patchset 39 (Latest): // out safely in that case.
          Daniel Cheng . unresolved

          This is helpful, but maybe we should have a class-level comment that explains the threading preconditions/postconditions of this class.

          The current comment looks something like:
          ```
          // It is partially sequence-affine with several public methods that must be
          // called on the sequence to which the MultiplexRouter is bound. See the
          // constructor for details.
          ```

          which doesn't really help readers (e.g. me :P) understand the requirements.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Emily Andrews
          • Reilly Grant
          • Stefan Smolen
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
            Gerrit-Comment-Date: Wed, 22 Apr 2026 18:58:32 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Daniel Cheng (Gerrit)

            unread,
            Apr 22, 2026, 4:24:19 PMApr 22
            to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
            Attention needed from Emily Andrews, Reilly Grant and Stefan Smolen

            Daniel Cheng added 9 comments

            File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
            Line 339, Patchset 39:TEST_F(MultiplexRouterTest, CloseMessagePipeReleasesRouterSelfReference) {
            Daniel Cheng . unresolved

            Probably missing something here but I'm a little fuzzy on where the self reference is coming from (as it seems like the test fixture itself also owns references, so I'm not quite sure what we're trying to exercise here)

            Line 377, Patchset 39:TEST_F(MultiplexRouterTest, PassMessagePipe) {
            Daniel Cheng . unresolved

            I think a high-level description of this test would be useful here.

            Line 441, Patchset 39: // Now hook up a new router2 to prove we can continue using router1_
            Daniel Cheng . unresolved

            Because I don't understand why this is important, or how this handles normally without reading things in a lot more details. I think this is supposed to be true because we passed the message pipe above by extracting it and are moving it to another route, hence reuse is OK, but I had to read the test body twice. And I'm still not quite sure why the association bits are significant yet.

            Line 491, Patchset 39: std::string(reinterpret_cast<const char*>(response.payload())));
            Daniel Cheng . unresolved

            The std::string probably isn't necessary here, though I suppose it doesn't hurt either.

            Line 613, Patchset 39:TEST_F(MultiplexRouterLifetimeFixTest, PendingMessagesCleanedUpDuringDestruction) {
            Daniel Cheng . unresolved

            Nit: wrap at 80 (run `git cl format`?)

            Line 708, Patchset 39: base::BindOnce(
            Daniel Cheng . unresolved

            Judicious use of BindLambdaForTesting could simplify some of these, e.g.:

            ```
            ...->PostTask(FROM_HERE, base::BindLambdaForTesting(
            [r0 = std::move(router0), r1 = std::move(Router1), main_runner, &run_loop] {
            }));
            ```
            File mojo/public/cpp/bindings/tests/race_condition_scheduler.h
            Line 29, Patchset 39: void ScheduleDeathAndWait(base::OnceClosure callback);
            Daniel Cheng . unresolved

            And death of what? et cetera

            Line 26, Patchset 39: void ScheduleOnWatcherHandleReady(base::OnceClosure callback,
            Daniel Cheng . unresolved

            Can we add some basic comments here? For example, what watcher handle is this?

            File mojo/public/cpp/bindings/tests/testable_multiplex_router.cc
            Line 57, Patchset 39: // We don't want to hang forever, this should signal eventually.
            Daniel Cheng . unresolved

            It would be a test bug if this wasn't signalled though right? Why not just wait forever and let tests timeout in case of a bug?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Emily Andrews
            • Reilly Grant
            • Stefan Smolen
            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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
            Gerrit-Change-Number: 7164260
            Gerrit-PatchSet: 40
            Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
            Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
            Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
            Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
            Gerrit-CC: Jiewei Qian <q...@chromium.org>
            Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
            Gerrit-CC: Reilly Grant <rei...@chromium.org>
            Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
            Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-Attention: Reilly Grant <rei...@chromium.org>
            Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
            Gerrit-Comment-Date: Wed, 22 Apr 2026 20:24:13 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Emily Andrews (Gerrit)

            unread,
            Apr 28, 2026, 3:30:55 PMApr 28
            to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
            Attention needed from Reilly Grant and Stefan Smolen

            Emily Andrews voted Commit-Queue+2

            Commit-Queue+2
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Reilly Grant
            • Stefan Smolen
            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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
            Gerrit-Change-Number: 7164260
            Gerrit-PatchSet: 82
            Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
            Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
            Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
            Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
            Gerrit-CC: Jiewei Qian <q...@chromium.org>
            Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
            Gerrit-CC: Reilly Grant <rei...@chromium.org>
            Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
            Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-Attention: Reilly Grant <rei...@chromium.org>
            Gerrit-Comment-Date: Tue, 28 Apr 2026 19:30:50 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Emily Andrews (Gerrit)

            unread,
            Apr 28, 2026, 3:45:13 PMApr 28
            to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
            Attention needed from Reilly Grant and Stefan Smolen

            Emily Andrews voted Commit-Queue+2

            Commit-Queue+2
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Reilly Grant
            • Stefan Smolen
            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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
            Gerrit-Change-Number: 7164260
            Gerrit-PatchSet: 83
            Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
            Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
            Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
            Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
            Gerrit-CC: Jiewei Qian <q...@chromium.org>
            Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
            Gerrit-CC: Reilly Grant <rei...@chromium.org>
            Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
            Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-Attention: Reilly Grant <rei...@chromium.org>
            Gerrit-Comment-Date: Tue, 28 Apr 2026 19:45:09 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Emily Andrews (Gerrit)

            unread,
            Apr 28, 2026, 5:04:40 PMApr 28
            to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
            Attention needed from Reilly Grant and Stefan Smolen

            Emily Andrews voted Commit-Queue+2

            Commit-Queue+2
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Reilly Grant
            • Stefan Smolen
            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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
            Gerrit-Change-Number: 7164260
            Gerrit-PatchSet: 84
            Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
            Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
            Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
            Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
            Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
            Gerrit-CC: Jiewei Qian <q...@chromium.org>
            Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
            Gerrit-CC: Reilly Grant <rei...@chromium.org>
            Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
            Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
            Gerrit-Attention: Reilly Grant <rei...@chromium.org>
            Gerrit-Comment-Date: Tue, 28 Apr 2026 21:04:34 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Emily Andrews (Gerrit)

            unread,
            May 22, 2026, 5:01:50 PM (6 days ago) May 22
            to Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
            Attention needed from Daniel Cheng, Reilly Grant and Stefan Smolen

            Emily Andrews added 17 comments

            Patchset-level comments
            File-level comment, Patchset 120 (Latest):
            Emily Andrews . resolved

            Ok I think this should be resolved. I have a separate PR for the WebNN tests that needs to go in first, but after that this should be g2g.

            File ipc/ipc_mojo_bootstrap.cc
            Line 198, Patchset 39: delete this;
            Daniel Cheng . resolved

            Let's explain why `delete this` unconditionally is safe here, i.e. what precondition guarantees that this is safe.

            Emily Andrews

            I've refactored this class so it should handle any potential shutdown/handle error races properly.

            File mojo/public/cpp/bindings/connector.h
            Line 260, Patchset 39: base::WeakPtr<Connector> GetWeakPtrForTesting() {
            Daniel Cheng . resolved

            Fine to make this public (especially if that avoids the need for a `friend`)

            Emily Andrews

            Done

            File mojo/public/cpp/bindings/lib/multiplex_router.h
            Line 156, Patchset 39: void DeleteOnCorrectSequence() const override;
            Daniel Cheng . resolved

            Nit: group this with the other AGC methods

            Emily Andrews

            Done

            File mojo/public/cpp/bindings/lib/multiplex_router.cc
            Line 45, Patchset 39:// This performs 3 atomic operations (TryAddRef + AddRef + Release) because

            // scoped_refptr has no public constructor that adopts an existing ref without
            // calling AddRef. The private AdoptRefTag constructor is restricted to
            // AdoptRef(), which requires REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE and
            // HasOneRef() — neither of which hold here.
            Daniel Cheng . resolved

            I think we can extend `scoped_refptr`'s API/helpers to support this so we don't need the extra refcount churn.

            I don't have a good name for this though; to be honest, it is really bizarre to pass around a `T*` to which the refcount is zero, because if the refcount is zero, the object is at best partially valid...

            Emily Andrews

            ok so I shifted gears, we post the last release on the sequence. This means that the Connector::HandleError call will be canceled when it's deleted.

            Line 662, Patchset 39: auto prevent_destroy = TryMakeScopedRefPtr(this);
            Daniel Cheng . resolved

            Can we add a comment here? Presumably the destructor is potentially already on the stack here, but we can explain what scenario this could happen in.

            Emily Andrews

            We're posting with the WrapRefCounted AddRef helper so I think this is safe now.

            Line 718, Patchset 39: auto prevent_destroy = TryMakeScopedRefPtr(this);
            Daniel Cheng . resolved

            Same comment here.

            Emily Andrews

            Done

            Line 1005, Patchset 39: // out safely in that case.
            Daniel Cheng . resolved

            This is helpful, but maybe we should have a class-level comment that explains the threading preconditions/postconditions of this class.

            The current comment looks something like:
            ```
            // It is partially sequence-affine with several public methods that must be
            // called on the sequence to which the MultiplexRouter is bound. See the
            // constructor for details.
            ```

            which doesn't really help readers (e.g. me :P) understand the requirements.

            Emily Andrews

            I think because we've fixed the Release sequencing maybe it's less important?

            File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
            Line 339, Patchset 39:TEST_F(MultiplexRouterTest, CloseMessagePipeReleasesRouterSelfReference) {
            Daniel Cheng . resolved

            Probably missing something here but I'm a little fuzzy on where the self reference is coming from (as it seems like the test fixture itself also owns references, so I'm not quite sure what we're trying to exercise here)

            Emily Andrews

            I think this test is probably out of date. This is from when I was passing in the ref to the connector.

            Line 377, Patchset 39:TEST_F(MultiplexRouterTest, PassMessagePipe) {
            Daniel Cheng . resolved

            I think a high-level description of this test would be useful here.

            Emily Andrews

            Done

            Line 441, Patchset 39: // Now hook up a new router2 to prove we can continue using router1_
            Daniel Cheng . resolved

            Because I don't understand why this is important, or how this handles normally without reading things in a lot more details. I think this is supposed to be true because we passed the message pipe above by extracting it and are moving it to another route, hence reuse is OK, but I had to read the test body twice. And I'm still not quite sure why the association bits are significant yet.

            Emily Andrews

            This is used by the Remote::Unbind and then Remote::Bind API to move the mojo remote to different threads. I have documented it.

            Line 491, Patchset 39: std::string(reinterpret_cast<const char*>(response.payload())));
            Daniel Cheng . resolved

            The std::string probably isn't necessary here, though I suppose it doesn't hurt either.

            Emily Andrews

            Removing this here and in the other tests in this file.

            Line 613, Patchset 39:TEST_F(MultiplexRouterLifetimeFixTest, PendingMessagesCleanedUpDuringDestruction) {
            Daniel Cheng . resolved

            Nit: wrap at 80 (run `git cl format`?)

            Emily Andrews

            Done

            Line 708, Patchset 39: base::BindOnce(
            Daniel Cheng . resolved

            Judicious use of BindLambdaForTesting could simplify some of these, e.g.:

            ```
            ...->PostTask(FROM_HERE, base::BindLambdaForTesting(
            [r0 = std::move(router0), r1 = std::move(Router1), main_runner, &run_loop] {
            }));
            ```
            Emily Andrews

            Done

            File mojo/public/cpp/bindings/tests/race_condition_scheduler.h
            Line 29, Patchset 39: void ScheduleDeathAndWait(base::OnceClosure callback);
            Daniel Cheng . resolved

            And death of what? et cetera

            Emily Andrews

            Done

            Line 26, Patchset 39: void ScheduleOnWatcherHandleReady(base::OnceClosure callback,
            Daniel Cheng . resolved

            Can we add some basic comments here? For example, what watcher handle is this?

            Emily Andrews

            Done

            File mojo/public/cpp/bindings/tests/testable_multiplex_router.cc
            Line 57, Patchset 39: // We don't want to hang forever, this should signal eventually.
            Daniel Cheng . resolved

            It would be a test bug if this wasn't signalled though right? Why not just wait forever and let tests timeout in case of a bug?

            Emily Andrews

            TimedWait returns false if it isn't signaled, which would cause the test to fail explicitly and not also cause the test pipeline to take an obscene amount of time before failing.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Daniel Cheng
            • Reilly Grant
            • Stefan Smolen
            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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
              Gerrit-Change-Number: 7164260
              Gerrit-PatchSet: 120
              Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
              Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
              Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
              Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
              Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
              Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
              Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
              Gerrit-CC: Jiewei Qian <q...@chromium.org>
              Gerrit-CC: Rafael Cintron <rafael....@microsoft.com>
              Gerrit-CC: Reilly Grant <rei...@chromium.org>
              Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
              Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
              Gerrit-Attention: Reilly Grant <rei...@chromium.org>
              Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
              Gerrit-Comment-Date: Fri, 22 May 2026 21:01:37 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Daniel Cheng (Gerrit)

              unread,
              May 23, 2026, 3:36:43 PM (5 days ago) May 23
              to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Reilly Grant, Rafael Cintron, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
              Attention needed from Emily Andrews, Reilly Grant and Stefan Smolen

              Daniel Cheng added 4 comments

              Patchset-level comments
              Daniel Cheng . resolved

              Thanks for working through this; I know it's been a bit of a mess. A few (hopefully last) questions from my side

              File mojo/public/cpp/bindings/lib/associated_group_controller.cc
              Line 22, Patchset 120 (Latest): if (bound_task_runner_ && !bound_task_runner_->RunsTasksInCurrentSequence()) {
              Daniel Cheng . unresolved

              Remind me why this might be null?

              Line 31, Patchset 120 (Latest): // release — may delete off-sequence, same as pre-fix behavior.
              Daniel Cheng . unresolved

              We should be safe in this case, or can the sequence be running the error handler?

              i.e. if PostTask() fails is that a promise to never run more tasks?

              File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
              Line 134, Patchset 120 (Latest): EXPECT_EQ(std::string_view("hello again world!"), GetPayloadAsStringView(response));
              Daniel Cheng . unresolved

              Nit: git cl format this CL for wrapping

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Emily Andrews
              • Reilly Grant
              • Stefan Smolen
              Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement is not satisfiedCode-Owners
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                Gerrit-Comment-Date: Sat, 23 May 2026 19:36:28 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Emily Andrews (Gerrit)

                unread,
                May 26, 2026, 2:52:25 PM (2 days ago) May 26
                to Xu, Mingming1, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                Attention needed from Daniel Cheng and Stefan Smolen

                Emily Andrews voted and added 4 comments

                Votes added by Emily Andrews

                Commit-Queue+1

                4 comments

                Patchset-level comments
                File-level comment, Patchset 121 (Latest):
                Emily Andrews . resolved

                Addressed CL comments

                File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                Line 22, Patchset 120: if (bound_task_runner_ && !bound_task_runner_->RunsTasksInCurrentSequence()) {
                Daniel Cheng . resolved

                Remind me why this might be null?

                Emily Andrews

                I don't think it should be, so I added a CHECK to guard against a programming error.

                Line 31, Patchset 120: // release — may delete off-sequence, same as pre-fix behavior.
                Daniel Cheng . resolved

                We should be safe in this case, or can the sequence be running the error handler?

                i.e. if PostTask() fails is that a promise to never run more tasks?

                Emily Andrews

                According to the PostTask documentation, if it's true it might execute and if it's false it's guaranteed not to execute. https://source.chromium.org/chromium/chromium/src/+/main:base/task/task_runner.h;l=63-65

                File mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc
                Line 134, Patchset 120: EXPECT_EQ(std::string_view("hello again world!"), GetPayloadAsStringView(response));
                Daniel Cheng . resolved

                Nit: git cl format this CL for wrapping

                Emily Andrews

                Done

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Daniel Cheng
                • Stefan Smolen
                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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                  Gerrit-Change-Number: 7164260
                  Gerrit-PatchSet: 121
                  Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                  Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                  Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                  Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                  Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                  Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                  Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                  Gerrit-CC: Jiewei Qian <q...@chromium.org>
                  Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
                  Gerrit-Comment-Date: Tue, 26 May 2026 18:52:15 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: Yes
                  Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Daniel Cheng (Gerrit)

                  unread,
                  May 26, 2026, 4:58:32 PM (2 days ago) May 26
                  to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                  Attention needed from Emily Andrews and Stefan Smolen

                  Daniel Cheng added 1 comment

                  File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                  Line 31, Patchset 120: // release — may delete off-sequence, same as pre-fix behavior.
                  Daniel Cheng . unresolved

                  We should be safe in this case, or can the sequence be running the error handler?

                  i.e. if PostTask() fails is that a promise to never run more tasks?

                  Emily Andrews

                  According to the PostTask documentation, if it's true it might execute and if it's false it's guaranteed not to execute. https://source.chromium.org/chromium/chromium/src/+/main:base/task/task_runner.h;l=63-65

                  Daniel Cheng

                  This really only happens when the process is shutting down, so I think I'm OK just not handling the `PostTask()` failed case and leaking.

                  (I've noticed things increasingly trying to handle the `PostTask()` return value, and I feel that is generally not necessary, and I'll be attempting to remove this from `PostTask()` at some point; removing this branch saves me a bit of work down the road :)

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Emily Andrews
                  • Stefan Smolen
                  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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                    Gerrit-Change-Number: 7164260
                    Gerrit-PatchSet: 121
                    Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                    Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                    Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                    Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                    Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                    Gerrit-CC: Jiewei Qian <q...@chromium.org>
                    Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
                    Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
                    Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                    Gerrit-Comment-Date: Tue, 26 May 2026 20:58:21 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Emily Andrews (Gerrit)

                    unread,
                    May 26, 2026, 11:48:53 PM (2 days ago) May 26
                    to Xu, Mingming1, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                    Attention needed from Daniel Cheng and Stefan Smolen

                    Emily Andrews added 2 comments

                    Patchset-level comments
                    Emily Andrews . resolved

                    I think we need to handle PostTask failing in the Release because otherwise we can get ASAN bugs if the task runner the MultiplexRouter is running on is shutdown before all the refs are released.

                    File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                    Line 31, Patchset 120: // release — may delete off-sequence, same as pre-fix behavior.
                    Daniel Cheng . resolved

                    We should be safe in this case, or can the sequence be running the error handler?

                    i.e. if PostTask() fails is that a promise to never run more tasks?

                    Emily Andrews

                    According to the PostTask documentation, if it's true it might execute and if it's false it's guaranteed not to execute. https://source.chromium.org/chromium/chromium/src/+/main:base/task/task_runner.h;l=63-65

                    Daniel Cheng

                    This really only happens when the process is shutting down, so I think I'm OK just not handling the `PostTask()` failed case and leaking.

                    (I've noticed things increasingly trying to handle the `PostTask()` return value, and I feel that is generally not necessary, and I'll be attempting to remove this from `PostTask()` at some point; removing this branch saves me a bit of work down the road :)

                    Emily Andrews

                    I'd rather not, because what can happen in test code is that the task runner gets shut down and then we get ASAN bugs galore.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Daniel Cheng
                    • Stefan Smolen
                    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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                      Gerrit-Change-Number: 7164260
                      Gerrit-PatchSet: 121
                      Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                      Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                      Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                      Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                      Gerrit-CC: Jiewei Qian <q...@chromium.org>
                      Gerrit-CC: Xu, Mingming1 <mingmi...@intel.com>
                      Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
                      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
                      Gerrit-Comment-Date: Wed, 27 May 2026 03:48:44 +0000
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy

                      Daniel Cheng (Gerrit)

                      unread,
                      May 27, 2026, 3:36:24 AM (yesterday) May 27
                      to Emily Andrews, Xu, Mingming1, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                      Attention needed from Emily Andrews and Stefan Smolen

                      Daniel Cheng added 2 comments

                      Patchset-level comments
                      Emily Andrews . resolved

                      I think we need to handle PostTask failing in the Release because otherwise we can get ASAN bugs if the task runner the MultiplexRouter is running on is shutdown before all the refs are released.

                      Daniel Cheng

                      In that case, we should just leak it and not release.

                      File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                      Line 31, Patchset 120: // release — may delete off-sequence, same as pre-fix behavior.
                      Daniel Cheng . resolved

                      We should be safe in this case, or can the sequence be running the error handler?

                      i.e. if PostTask() fails is that a promise to never run more tasks?

                      Emily Andrews

                      According to the PostTask documentation, if it's true it might execute and if it's false it's guaranteed not to execute. https://source.chromium.org/chromium/chromium/src/+/main:base/task/task_runner.h;l=63-65

                      Daniel Cheng

                      This really only happens when the process is shutting down, so I think I'm OK just not handling the `PostTask()` failed case and leaking.

                      (I've noticed things increasingly trying to handle the `PostTask()` return value, and I feel that is generally not necessary, and I'll be attempting to remove this from `PostTask()` at some point; removing this branch saves me a bit of work down the road :)

                      Emily Andrews

                      I'd rather not, because what can happen in test code is that the task runner gets shut down and then we get ASAN bugs galore.

                      Daniel Cheng

                      Task runners don't shut down outside of process shutdown.

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Emily Andrews
                      • Stefan Smolen
                      Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Comment-Date: Wed, 27 May 2026 07:36:09 +0000
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy

                      Emily Andrews (Gerrit)

                      unread,
                      May 27, 2026, 2:07:02 PM (yesterday) May 27
                      to Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                      Attention needed from Daniel Cheng and Stefan Smolen

                      Emily Andrews added 2 comments

                      Patchset-level comments
                      Emily Andrews . resolved

                      I think we need to handle PostTask failing in the Release because otherwise we can get ASAN bugs if the task runner the MultiplexRouter is running on is shutdown before all the refs are released.

                      Daniel Cheng

                      In that case, we should just leak it and not release.

                      Emily Andrews

                      If we leak it, then we will get ASAN test failures because the memory doesn't get cleaned up.

                      Emily Andrews . resolved

                      ASAN tests will fail if objects are leaked. It does not matter if it doesn't impact production code and it only happens during process shutdown in the real world, etc. I think we need to just release the object if the PostTask fails to avoid the ASAN test failures, and I have spent like 4 months fixing them. The alternative is we provide some sort of a hook to wait on for tests where an event is signaled indicating destruction, but I've received previous feedback that there's a preference for not doing that.

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Daniel Cheng
                      • Stefan Smolen
                      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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                      Gerrit-Change-Number: 7164260
                      Gerrit-PatchSet: 121
                      Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                      Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                      Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                      Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                      Gerrit-CC: Jiewei Qian <q...@chromium.org>
                      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
                      Gerrit-Comment-Date: Wed, 27 May 2026 18:06:53 +0000
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy

                      Daniel Cheng (Gerrit)

                      unread,
                      May 27, 2026, 2:28:46 PM (yesterday) May 27
                      to Emily Andrews, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, Daniel Cheng, chromium...@chromium.org, gavinp...@chromium.org
                      Attention needed from Emily Andrews and Stefan Smolen

                      Daniel Cheng added 1 comment

                      Patchset-level comments
                      Emily Andrews . resolved

                      I think we need to handle PostTask failing in the Release because otherwise we can get ASAN bugs if the task runner the MultiplexRouter is running on is shutdown before all the refs are released.

                      Daniel Cheng

                      In that case, we should just leak it and not release.

                      Emily Andrews

                      If we leak it, then we will get ASAN test failures because the memory doesn't get cleaned up.

                      Daniel Cheng

                      Yes, but does that happen in practice?

                      If it really does, we can just mark the object as potentially leaked. We already have precedent for that, e.g. https://source.chromium.org/chromium/chromium/src/+/main:base/threading/post_task_and_reply_impl.cc;l=83;drc=099aa05d9202a1953d8da94e110c0c5463f6f90e if we really need to take that path.

                      I don't think we really want to handle the return value of PostTask() here ultimately. And leaking it is still safer than running a `delete this` that might race with still-running tasks, even if the task runner is no longer accepting new tasks due to process shutdown.

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Emily Andrews
                      • Stefan Smolen
                      Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Comment-Date: Wed, 27 May 2026 18:28:38 +0000
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy

                      Daniel Cheng (Gerrit)

                      unread,
                      May 27, 2026, 5:26:45 PM (24 hours ago) May 27
                      to Emily Andrews, Daniel Cheng, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, chromium...@chromium.org, gavinp...@chromium.org
                      Attention needed from Emily Andrews and Stefan Smolen

                      Daniel Cheng voted and added 1 comment

                      Votes added by Daniel Cheng

                      Code-Review+1

                      1 comment

                      File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                      Line 27, Patchset 123 (Latest): // so we mark the object as leaking in case the PostTask fails.
                      Daniel Cheng . unresolved
                      ```suggestion
                      // so we mark the object as leaking in case the PostTask fails,
                      // i.e. at browser shutdown.
                      ```
                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Emily Andrews
                      • Stefan Smolen
                      Submit Requirements:
                      • requirement satisfiedCode-Coverage
                      • requirement 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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                      Gerrit-Change-Number: 7164260
                      Gerrit-PatchSet: 123
                      Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                      Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                      Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                      Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                      Gerrit-CC: Jiewei Qian <q...@chromium.org>
                      Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
                      Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                      Gerrit-Comment-Date: Wed, 27 May 2026 21:26:31 +0000
                      Gerrit-HasComments: Yes
                      Gerrit-Has-Labels: Yes
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy

                      Emily Andrews (Gerrit)

                      unread,
                      3:38 PM (1 hour ago) 3:38 PM
                      to Daniel Cheng, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, chromium...@chromium.org, gavinp...@chromium.org
                      Attention needed from Daniel Cheng and Stefan Smolen

                      Emily Andrews added 2 comments

                      Patchset-level comments
                      File-level comment, Patchset 124:
                      Emily Andrews . resolved

                      Alright should be GTG, had to resolve some merge conflicts.

                      File mojo/public/cpp/bindings/lib/associated_group_controller.cc
                      Line 27, Patchset 123: // so we mark the object as leaking in case the PostTask fails.
                      Daniel Cheng . resolved
                      ```suggestion
                      // so we mark the object as leaking in case the PostTask fails,
                      // i.e. at browser shutdown.
                      ```
                      Emily Andrews

                      Fix applied.

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Daniel Cheng
                      • Stefan Smolen
                      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: I07e47ea0e8e420274223eadfd09c0c8519e5dd94
                        Gerrit-Change-Number: 7164260
                        Gerrit-PatchSet: 125
                        Gerrit-Owner: Emily Andrews <emi...@microsoft.com>
                        Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
                        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
                        Gerrit-Reviewer: Emily Andrews <emi...@microsoft.com>
                        Gerrit-Reviewer: Stefan Smolen <ssm...@microsoft.com>
                        Gerrit-CC: Bernhart, Bryan <bryan.b...@intel.com>
                        Gerrit-CC: Hu, Ningxin <ningx...@intel.com>
                        Gerrit-CC: Jiewei Qian <q...@chromium.org>
                        Gerrit-Attention: Stefan Smolen <ssm...@microsoft.com>
                        Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
                        Gerrit-Comment-Date: Thu, 28 May 2026 19:37:59 +0000
                        Gerrit-HasComments: Yes
                        Gerrit-Has-Labels: No
                        Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
                        satisfied_requirement
                        unsatisfied_requirement
                        open
                        diffy

                        Daniel Cheng (Gerrit)

                        unread,
                        3:43 PM (1 hour ago) 3:43 PM
                        to Emily Andrews, Daniel Cheng, Bernhart, Bryan, Jiewei Qian, Hu, Ningxin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, Stefan Smolen, chromium...@chromium.org, gavinp...@chromium.org
                        Attention needed from Emily Andrews and Stefan Smolen

                        Daniel Cheng voted Code-Review+1

                        Code-Review+1
                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Emily Andrews
                        • Stefan Smolen
                        Gerrit-Attention: Emily Andrews <emi...@microsoft.com>
                        Gerrit-Comment-Date: Thu, 28 May 2026 19:43:22 +0000
                        Gerrit-HasComments: No
                        Gerrit-Has-Labels: Yes
                        satisfied_requirement
                        unsatisfied_requirement
                        open
                        diffy
                        Reply all
                        Reply to author
                        Forward
                        0 new messages