Skip to content

Teardown does not work on OSX #2973

@rgrinberg

Description

@rgrinberg

The following test (dune-cache-trimming/run.t) never terminates (consistently) for me on Mac:

Check background trimming.

  $ env DUNE_CACHE=enabled DUNE_CACHE_TRIM_SIZE=1 DUNE_CACHE_TRIM_PERIOD=1 XDG_RUNTIME_DIR=$PWD/.xdg-runtime XDG_CACHE_HOME=$PWD/.xdg-cache dune cache start > /dev/null 2>&1
  $ env DUNE_CACHE=enabled DUNE_CACHE_EXIT_NO_CLIENT=1 XDG_RUNTIME_DIR=$PWD/.xdg-runtime XDG_CACHE_HOME=$PWD/.xdg-cache dune build target_a
  $ rm -f _build/default/target_a _build/default/beacon_a
  $ sleep 2
  $ env DUNE_CACHE=enabled DUNE_CACHE_EXIT_NO_CLIENT=1 XDG_RUNTIME_DIR=$PWD/.xdg-runtime XDG_CACHE_HOME=$PWD/.xdg-cache dune build target_a
  $ test -e _build/default/beacon_a
  $ env DUNE_CACHE=enabled XDG_RUNTIME_DIR=$PWD/.xdg-runtime XDG_CACHE_HOME=$PWD/.xdg-cache dune cache stop

The following call to teardown triggers a clean up process:

  | Some { cache = (module Caching : Dune_cache.Caching); _ } ->
    (* Synchronously wait for the end of the connection with the cache daemon,
       ensuring all dedup messages have been queued. *)
    Caching.Cache.teardown Caching.cache;

That doesn't seem to terminate. This shutdown call:

  let teardown client =
    ( try Unix.shutdown client.fd Unix.SHUTDOWN_SEND
      with Unix.Unix_error (Unix.ENOTCONN, _, _) -> () );
    Thread.join client.thread

Never seems to terminate because the client thread is stuck reading:

  thread #5
    frame #0: 0x00007fff64f50c7e libsystem_kernel.dylib`read + 10
    frame #1: 0x0000000108927fb3 dune`caml_read_fd(fd=4, flags=<unavailable>, buf=0x0000000109565050, n=<unavailable>) at unix.c:79:15 [opt]
    frame #2: 0x000000010891dacb dune`caml_ml_input(vchannel=4449792192, buff=<unavailable>, vstart=<unavailable>, vlength=<unavailable>) at io.c:774:13 [opt]
    frame #3: 0x00000001088b44af dune`camlStdlib__input_264 + 79
    frame #4: 0x00000001088cca48 dune`camlStdlib__stream__fill_buff_121 + 56
    frame #5: 0x00000001088ccf51 dune`camlStdlib__stream__peek_data_223 + 497
    frame #6: 0x00000001088a72a2 dune`camlStdune__Csexp__peek_204 + 18
    frame #7: 0x00000001088a7667 dune`camlStdune__Csexp__parse_451 + 103
    frame #8: 0x0000000108860ea7 dune`camlDune_cache_daemon__read_2792 + 103
    frame #9: 0x000000010886361f dune`camlDune_cache_daemon__thread_3571 + 111
    frame #10: 0x000000010886772b dune`camlThread__fun_286 + 43
    frame #11: 0x0000000108931478 dune`caml_start_program + 92
    frame #12: 0x0000000108905da8 dune`caml_thread_start + 104
    frame #13: 0x00007fff65013e65 libsystem_pthread.dylib`_pthread_start + 148
    frame #14: 0x00007fff6500f83b libsystem_pthread.dylib`thread_start + 15

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions