From 9f6e9b40d395355b678ce3bdd4d62de5dcecdfb3 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Tue, 11 Sep 2018 14:38:05 +0000 Subject: [PATCH] mjit_worker.c: atomically print main message and \n To attempt to fix CI failure on rubyci freebsd: https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd11zfs/ruby-trunk/log/20180911T123001Z.fail.html.gz ``` JIT success (68.7ms): mjit9@(eval):1 -> /usr/home/hsbt/chkbuild/tmp/build/20180911T123001Z/tmp/jit_test_unload_units_20180911-96427-13cagj9/_ruby_mjit_p99188u9.c JIT compaction (25.1ms): Compacted 10 methods -> /usr/home/hsbt/chkbuild/tmp/build/20180911T123001Z/tmp/jit_test_unload_units_20180911-96427-13cagj9/_ruby_mjit_p99188u10.soToo many JIT code -- 1 units unloaded JIT success (68.2ms): mjit10@(eval):1 -> /usr/home/hsbt/chkbuild/tmp/build/20180911T123001Z/tmp/jit_test_unload_units_20180911-96427-13cagj9/_ruby_mjit_p99188u11.c ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit_worker.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mjit_worker.c b/mjit_worker.c index d0adf5d1fc..f1404b6aab 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -290,11 +290,17 @@ verbose(int level, const char *format, ...) { if (mjit_opts.verbose >= level) { va_list args; + size_t len = strlen(format); + char *full_format = alloca(sizeof(char) * (len + 2)); + + /* Creating `format + '\n'` to atomically print format and '\n'. */ + memcpy(full_format, format, len); + full_format[len] = '\n'; + full_format[len+1] = '\0'; va_start(args, format); - vfprintf(stderr, format, args); + vfprintf(stderr, full_format, args); va_end(args); - fprintf(stderr, "\n"); } }