https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110394

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2023-06-24
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am almost think this is a bug in your code.
Take:

  auto wait_handle = tc::g_postbox->wait(
    "UpdateInputs"sv, [=](const msgpack::object& obj) -> bool {
    ....
  });


The temporary for tc::postbox::acceptor_type will end its lifetime at the end
of that statement but tc::g_postbox->wait stores it off into m_awaiters.

And then gets poped off with:
  wait_handle.await();


You can fix this via extending the temporary via:
```
  tc::postbox::acceptor_type t = [=](const msgpack::object& obj) -> bool {
    auto [rcv_index, rcv_value] = obj.as<std::tuple<int, uint32_t>>();
    tc::tracef(M64MSG_VERBOSE, "index = {}", index);
    if (rcv_index != index)
      return false;

    keys->Value = rcv_value;
    return true;
  };
  auto wait_handle = tc::g_postbox->wait(
    "UpdateInputs"sv, t);

```


Note `-fsantize=address` should catch this at runtime too.

Reply via email to