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

Deadlock in Lwt_io due to simultaneous flushes #48

Closed
vouillon opened this issue Apr 1, 2014 · 0 comments
Closed

Deadlock in Lwt_io due to simultaneous flushes #48

vouillon opened this issue Apr 1, 2014 · 0 comments
Labels

Comments

@vouillon
Copy link
Member

vouillon commented Apr 1, 2014

The program below never terminates, despite the exit 0. What happens is that exit 0 attempts to flush the channel while Lwt_io.flush oc is still in progress.

let (>>=) = Lwt.bind
let flags =  [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_APPEND; Unix.O_NONBLOCK]
let _ =
Lwt_main.run
  (Lwt_unix.openfile "/tmp/out.txt" flags 0o666 >>= fun fd ->
   let oc = Lwt_io.of_fd ~mode:Lwt_io.output fd in
   ignore (Lwt_io.write oc "BUG" >>= fun () -> Lwt_io.flush oc);
   exit 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant