[BUG] Io.copy_channels
is called concurrently under Windows (at least), resulting in corrupted output
#11193
Labels
Io.copy_channels
is called concurrently under Windows (at least), resulting in corrupted output
#11193
Recently at LexiFi we observed what looks like a bug in Dune. When building a medium-size workspace under Windows, sometimes the target of
copy_files#
will get corrupted. Concretely, the workspace includes Menhir, and the filesrc/stage2/lexmli.ml
(which is anocamllex
-generated lexer and is copied usingcopy_files#
fromsrc/lexmli.ml
) is sometimes corrupted:For future reference, the symptom is that the compiler complained from an illegal backslash in this file:
Looking at the code
(copy_files# ...)
is implemented usingIo.copy_channels
fromstdune
which uses a global buffer:dune/otherlibs/stdune/src/io.ml
Lines 68 to 79 in 25be1ea
Accordingly, the first suspicion is that this function is called concurrently. To test this conjecture I instrumented the code:
and indeed, the function is called concurrently:
@rgrinberg: should we do the safe thing here and use a separate buffer for each call? (We could optimize that by using a global buffer but if the function is called again while the global buffer is being used, then use a fresh buffer.) What do you think?
The text was updated successfully, but these errors were encountered: