diff --git a/libc/src/__support/OSUtil/gpu/io.cpp b/libc/src/__support/OSUtil/gpu/io.cpp --- a/libc/src/__support/OSUtil/gpu/io.cpp +++ b/libc/src/__support/OSUtil/gpu/io.cpp @@ -16,7 +16,7 @@ void write_to_stderr(cpp::string_view msg) { rpc::Port port = rpc::client.open(rpc::PRINT_TO_STDERR); - port.send_n(msg.data(), msg.size() + 1); + port.send_n(msg.data(), msg.size()); port.close(); } diff --git a/libc/utils/gpu/loader/Server.h b/libc/utils/gpu/loader/Server.h --- a/libc/utils/gpu/loader/Server.h +++ b/libc/utils/gpu/loader/Server.h @@ -30,10 +30,15 @@ switch (port->get_opcode()) { case __llvm_libc::rpc::Opcode::PRINT_TO_STDERR: { - void *str = nullptr; - port->recv_n([&](uint64_t size) { return str = malloc(size); }); - fputs(reinterpret_cast(str), stderr); - free(str); + uint64_t str_size; + char *str = nullptr; + port->recv_n([&](uint64_t size) { + str_size = size; + str = new char[size]; + return str; + }); + fwrite(str, str_size, 1, stderr); + delete[] str; break; } case __llvm_libc::rpc::Opcode::EXIT: {