Skip to content

Commit 48cc447

Browse files
committed
dune: fix binary corruption during parallel promotion/install
Fixes #6668 When performing multiple promotions in parallel (e.g. for a .bc and an .exe) then sharing a single global buf means that one of them could get corrupted if the buffer is overwritten by the other build. Do not use global variables: allocate a new per-file buffer in 'parse' instead! `cd test && dune build @unit-tests/artifact_substitution/runtest @blackbox-tests/test-cases/versioncorruption` passes now Signed-off-by: Edwin Török <edvin.torok@citrix.com>
1 parent f26f1c0 commit 48cc447

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/dune_rules/artifact_substitution.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,6 @@ end
415415

416416
let buf_len = max_len
417417

418-
let buf = Bytes.create buf_len
419-
420418
type mode =
421419
| Test
422420
| Copy of
@@ -469,6 +467,7 @@ output the replacement | |
469467
v} *)
470468
let parse ~input ~mode =
471469
let open Fiber.O in
470+
let buf = Bytes.create buf_len in
472471
let rec loop scanner_state ~beginning_of_data ~pos ~end_of_data ~status =
473472
let scanner_state = Scanner.run scanner_state ~buf ~pos ~end_of_data in
474473
let placeholder_start =

0 commit comments

Comments
 (0)