Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests in preview2 streams #6763

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Jul 24, 2023

#6556 introduced (at least) 2 flaky tests:

  • I made a bug in the sink_write_stream test in pipes. This test has been fixed, and the comment describes the race.
  • poll_oneoff_stdio is failed nondeterministically in the wasi-preview2-components-sync suite. We found a typo in the sync-to-async translation that caused this bug.

Thanks @silentbicycle, we used autoclave to reproduce this after a few hundred iterations:

RUST_LOG=wasmtime_wasi=trace autoclave cargo test -p test-programs --features test_programs --test wasi-preview2-components-sync -- poll_oneoff_stdio --nocapture

I didn't realize this test was racy, but it makes sense because the
worker is consuming these writes in another thread. usually the
foreground thread wins, but we observed the other case once in CI
@pchickey pchickey requested a review from a team as a code owner July 24, 2023 21:52
@pchickey pchickey requested review from fitzgen and removed request for a team July 24, 2023 21:52
@alexcrichton alexcrichton enabled auto-merge July 24, 2023 22:05
@alexcrichton alexcrichton added this pull request to the merge queue Jul 24, 2023
@pchickey pchickey removed this pull request from the merge queue due to a manual request Jul 24, 2023
I made a typo translating the sync calls to async calls, and in the sync
implementation stream::blocking_write was calling async stream::write,
so it was missing the logic to make the write blocking.

This would in turn cause panics in rust's std::io::stdio::print_to
when writes return less than the length of the input.

thank you to @silentbicycle for autoclave, which we used to reproduce
this bug.
@pchickey pchickey force-pushed the pch/preview2_streams_flaky_tests branch from aa52d22 to 2afbede Compare July 24, 2023 22:38
@pchickey pchickey requested a review from alexcrichton July 24, 2023 22:39
@pchickey
Copy link
Contributor Author

Yanked from the merge queue because we found the bug, so instead of ignoring the test the bug is now fixed.

@pchickey pchickey enabled auto-merge July 24, 2023 22:42
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Jul 24, 2023
@pchickey pchickey added this pull request to the merge queue Jul 24, 2023
Merged via the queue into main with commit e81af41 Jul 24, 2023
@pchickey pchickey deleted the pch/preview2_streams_flaky_tests branch July 24, 2023 23:39
geekbeast pushed a commit to geekbeast/wasmtime that referenced this pull request Aug 1, 2023
* main: (47 commits)
  Add core dump support to the runtime (bytecodealliance#6513)
  Resource table tracks child relationships (bytecodealliance#6779)
  Wasmtime: Move `OnDemandInstanceAllocator` to its own module (bytecodealliance#6790)
  wasi: Test the stdio streams implementation (bytecodealliance#6764)
  Don't generate same-named imports in fact modules (bytecodealliance#6783)
  Wasmtime: Add support for Wasm tail calls (bytecodealliance#6774)
  Cranelift: Fix `ABIMachineSpec::gen_add_imm` for riscv64 (bytecodealliance#6780)
  Update the wasm-tools family of crates, disallow empty component types (bytecodealliance#6777)
  Fix broken link to WASI API documentation (bytecodealliance#6775)
  A bunch of cleanups for cranelift-codegen-meta (bytecodealliance#6772)
  Implement component-to-component calls with resources (bytecodealliance#6769)
  Ignore async_stack_size if async_support is disabled (bytecodealliance#6771)
  A bunch of minor cleanups (bytecodealliance#6767)
  Fix flaky tests in preview2 streams (bytecodealliance#6763)
  Refactor and simplify component trampolines (bytecodealliance#6751)
  Cranelift: Implement tail calls on riscv64 (bytecodealliance#6749)
  WASI Preview 2: rewrite streams and pollable implementation (bytecodealliance#6556)
  cranelift-wasm: Add support for translating Wasm tail calls to CLIF (bytecodealliance#6760)
  Cranelift: Get tail calls working on aarch64 (bytecodealliance#6723)
  Implement component model resources in Wasmtime (bytecodealliance#6691)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants