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

--- Comment #6 from Avi Kivity <avi at scylladb dot com> ---
Some more findings: if I replace the lambda (which is not a coroutine, but is
contained in a coroutine lambda) with an equivalent struct, the problem goes
away, both at runtime and in terms of an __old4 copy. 
+                struct inner_lambda {
+                    table* zis;
+                    lw_shared_ptr<memtable> old4;
+                    std::vector<sstables::shared_sstable>& newtabs;
+                    inner_lambda(table* zis, lw_shared_ptr<memtable>& old3,
std::vector<sstables::shared_sstable>& newtabs)
+                            : zis(zis), old4(old3), newtabs(newtabs) {}
+                    future<> operator()() {
+                        tlogger.info("updating cache {}",
fmt::ptr(old4.get()));
+                        return zis->update_cache(old4, newtabs);
+                    }
+                };
+
                 tlogger.info("before updating cache {}",
fmt::ptr(old3.get()));
-                co_await
with_scheduling_group(_config.memtable_to_cache_scheduling_group, [this, old4 =
old3, &newtabs] () -> future<> {
+                co_await
with_scheduling_group(_config.memtable_to_cache_scheduling_group, /* [this,
old4 = old3, &newtabs] () mutable -> future<> {
                     tlogger.info("updating cache {}", fmt::ptr(old4.get()));
                     return update_cache(old4, newtabs);
-                });
+                } */ inner_lambda(this, old3, newtabs));
                 tlogger.info("updating cache {} done", fmt::ptr(old3.get()));
                 _memtables->erase(old3);
                 tlogger.debug("Memtable for {}.{} replaced, into {} sstables",
old3->schema()->ks_name(), old3->schema()->cf_name(), newtabs.size());
                 tlogger.info("try_flush_memtable_to_sstable post_flush:end old
{} refcnt {}", fmt::ptr(old3.get()), old3.use_count());
                 co_return stop_iteration::yes;

Reply via email to