Skip to content

Commit

Permalink
Fix stack-use-after-return in mutation source excluding staging
Browse files Browse the repository at this point in the history
The new test detected a stack-use-after-return when using table's
as_mutation_source_excluding_staging() for range reads.

This doesn't really affect view updates that generate single
key reads only. So the problem was only stressed in the recently
added test. Otherwise, we'd have seen it when running dtests
(in debug mode) that stress the view update path from staging.

The problem happens because the closure was feeded into
a noncopyable_function that was taken by reference. For range
reads, we defer before subsequent usage of the predicate.
For single key reads, we only defer after finished using
the predicate.

Fix is about using sstable_predicate type, so there won't
be a need to construct a temporary object on stack.

Fixes #14812.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>

Closes #14813
  • Loading branch information
raphaelsc authored and denesb committed Jul 25, 2023
1 parent 3eec990 commit 0ac43ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion replica/table.cc
Expand Up @@ -2536,7 +2536,7 @@ table::make_reader_v2_excluding_staging(schema_ptr s,
readers.reserve(memtable_count + 1);
});

static std::predicate<const sstable&> auto excl_staging_predicate = [] (const sstable& sst) {
static const sstables::sstable_predicate excl_staging_predicate = [] (const sstable& sst) {
return !sst.requires_view_building();
};

Expand Down

0 comments on commit 0ac43ea

Please sign in to comment.