From f4352b63d3d0468ef7889dc26551c0f01dbee951 Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Wed, 2 Dec 2026 14:04:49 +0300 Subject: [PATCH] osd_test: Answer etcd calls one by one in test_peering_flush_same_epoch_repeer The test unpaused the etcd mock, which then answers a txn and its watch inside etcd_txn(). It passes only because the stopping PG's nested state report fails its compare and is retried from a timer. If that report succeeds, its callback erases the PG and stop_pg() goes on with the freed PG (a heap-use-after-free under ASan). Keep the mock paused and answer the queued calls one by one from the test, as a real etcd client does from the event loop. --- src/test/osd_test.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/osd_test.cpp b/src/test/osd_test.cpp index 5ec262a1..7656e12c 100644 --- a/src/test/osd_test.cpp +++ b/src/test/osd_test.cpp @@ -4930,7 +4930,9 @@ void test_peering_flush_same_epoch_repeer() assert(pg.flush_batch && !pg.flush_batch->flush_ops && pg.epoch == 1 && pg.reporting_epoch == 1); assert(std::count(pg.target_history.begin(), pg.target_history.end(), std::vector({ 3, 4 }))); - f.st_cli->resume(); + // Answer calls one by one, like a real etcd: unpaused, the mock calls back inside etcd_txn() + auto etcd_answer = [&]() { while (f.st_cli->queue.size()) f.st_cli->resume(1); }; + etcd_answer(); f.pump(); bool early = f.peer_has_sent_op(3, OSD_OP_SEC_STABILIZE); printf(" first report landed: etcd history %s, stabilize sent: %s\n", etcd_sets().c_str(), early ? "yes" : "no"); @@ -4940,7 +4942,9 @@ void test_peering_flush_same_epoch_repeer() answer_lists(); // A real watch advances this revision with every event, the mock doesn't; the history put compares against it f.st_cli->etcd_watch_revision_pg = f.etcd_store.mod_revision; + etcd_answer(); f.tfd->tick((timespec){ .tv_sec = 0, .tv_nsec = 500000000 }); + etcd_answer(); f.pump(); } printf(" then: etcd history %s, stabilize sent to OSDs 3, 4: %s, %s\n", etcd_sets().c_str(), -- 2.47.3