v3: - The last test run showed that the added tests are actually flaky. But given that buffer output did not fail and only length randomly got 0xdeadbeef I think it is the race on static variable usage (indicating some callbacks may race on Windows in such a process). I deduplicated the variable between callbacks and made it non-static for the case where static variable is not needed.