mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-04 22:13:19 +00:00
The implementation of sleep() looks like a game of Seastar golf - doing something in the minimum number of lines possible :-) Unfortunately, it looks very clever, but not quite right. sleep() usually works correctly, but the sanitizer (in the debug build) catches a use after free. The problem was that we delete an object which contains a timer which contains the callback (and std::function) - from inside this callback. The workaround in this patch is to use our future chaining to only delete the sleeper object after its future became ready - and at that point, none of the sleeper object or code is needed any more. This patch also includes a regression test for this issue. The test looks silly (just sleeps and checks nothing), but in the debugging build it failed (with a sanitizer reporting use-after-free) before this patch. Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>