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

Hanging Lwt_main.run case #549

Closed
koen-struyve opened this issue Feb 20, 2018 · 5 comments
Closed

Hanging Lwt_main.run case #549

koen-struyve opened this issue Feb 20, 2018 · 5 comments

Comments

@koen-struyve
Copy link

The following code snippet

let test () =
  let waiter, wakener = Lwt.task () in
  let wrapped_t =
    begin
      let%lwt () = Lwt_unix.yield () in
      Lwt.return ()
    end
    [%finally
      let () = Lwt.wakeup wakener () in
      Lwt.return ()
    ]
  in
  let%lwt () = waiter in
  wrapped_t

let () = Lwt_main.run (test ())

hangs indefinitely, with wrapped_t remaining in a Sleep state. We noted that binding on the result of "test ()" first seems to resolve this.

This behavior is present from version 3.1.0 onwards.

@aantron
Copy link
Collaborator

aantron commented Feb 24, 2018

Thanks for reporting. The attached commit fixes the issue. It is a bug in bind, catch, etc., that I accidentally introduced while reorganizing lwt.ml (#354). All the functions are fixed, and I also added test cases for all of them based on your snippet (thank you again).

I will look at couple more issues, and then make a release to make sure this fix reaches people soon.

@hcarty
Copy link
Contributor

hcarty commented Feb 27, 2018

I see something similar with 3.2.1 - haven't tested against master yet to know if it's the same issue but the hanging effect is the same:

let l : unit Lwt.t list = []

let _, _ = Lwt_main.run (Lwt.nchoose_split [])

will hang indefinitely. Tested in utop and compiled with ocamlopt, 64bit Linux w/libev.

@hcarty
Copy link
Contributor

hcarty commented Feb 27, 2018

Looks like this is a separate issue that exists after opam pin add lwt --dev-repo.

@hcarty
Copy link
Contributor

hcarty commented Feb 27, 2018

Issue opened in #551

@aantron
Copy link
Collaborator

aantron commented Mar 8, 2018

@koen-struyve the fix is now out in 3.3.0. Thanks again for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants