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

--- Comment #3 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Bisected it down to r15-3146-g47dbd69b1b31d3.

The real test is a bit involved as it requires a running an installtestsuite,
relies on boehm-gc and an interpreter language on top if it. I build it as:

    $ ./configure --prefix=$PWD/__i__
    $ make
    $ make install
    $ make installcheck

The unexpected failure is:
    $ make installcheck
    ...
    ran test tests/functional/binary-cache.sh... [FAIL]
    ...
    binary-cache.sh: line 41: 14211 Segmentation fault      (core dumped)
nix-store --substituters "file://$cacheDir" --no-require-sigs -r "$outPath"

I can easily test fixes locally against it.

I can attempt crafting executable example of this sample as well (need to wrap
my head around how one would run the coroutine). But the gist of it is the use
of passing rvalue reference in `await_transform()`: `Co&& await_transform(Co&&
co) { return static_cast<Co&&>(co); }`. I think we just destroy the promise
object within `co_await`.

In the real example `promise_type` for `Co` contains quite a bit of state and
it's destructor renders promise object as broken:
- `Co` / `promise_type` creation:
https://github.com/NixOS/nix/blob/2.24.9/src/libstore/build/substitution-goal.cc#L141
- `promise_type` object:
https://github.com/NixOS/nix/blob/2.24.9/src/libstore/build/goal.hh#L237

As an extra data point if I change `Co&& await_transform(Co&& co) { return
static_cast<Co&&>(co); }` to `Co await_transform(Co&& co) { return
std::move(co); }` both warning and the crash disappear.

Reply via email to