Skip to content

Commit 48cc3a0

Browse files
authored
Fix garbled output from concurrent threads in uplc-evaluator (#7555)
Set LineBuffering on stdout/stderr in both the service and test suite to prevent output interleaving when multiple threads write concurrently. This ensures each line is written atomically.
1 parent d9268b1 commit 48cc3a0

File tree

3 files changed

+895
-884
lines changed

3 files changed

+895
-884
lines changed

plutus-benchmark/plutus-benchmark.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,4 @@ test-suite uplc-evaluator-integration-tests
924924
, temporary
925925
, text
926926
, uuid
927+
, with-utf8

plutus-benchmark/uplc-evaluator/Main.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import PlutusPrelude (void)
3636
import System.Directory
3737
import System.Exit (exitFailure)
3838
import System.FilePath (takeBaseName, takeExtension, (</>))
39-
import System.IO (hPutStrLn, stderr)
39+
import System.IO (BufferMode (LineBuffering), hPutStrLn, hSetBuffering, stderr)
4040
import UntypedPlutusCore qualified as UPLC
4141
import UntypedPlutusCore.Evaluation.Machine.Cek qualified as Cek
4242
import UntypedPlutusCore.Parser qualified as UPLC.Parser
@@ -464,6 +464,7 @@ takeFileName = reverse . takeWhile (/= '/') . reverse
464464
-- | Main entry point
465465
main :: IO ()
466466
main = withUtf8 do
467+
hSetBuffering stderr LineBuffering -- Prevent garbled output from concurrent threads
467468
initializeTime -- Required before using getTime from criterion-measurement
468469
config <- execParser opts
469470
hPutStrLn stderr "UPLC Evaluator Service starting..."

0 commit comments

Comments
 (0)