runtime: Same code starting wkhtmltopdf process works on netcoreapp3.1 but fails on net5.0 on Linux
Description
Following code starting process and reading stdout works fine in netcoreapp3.1:
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Hello World!");
using (var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "wkhtmltopdf",
Arguments =
"-q -B 8 -L 8 -R 8 -T 8 --print-media-type --enable-local-file-access -s Letter -O Portrait - -",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
CreateNoWindow = true
}
})
{
process.Start();
byte[] array;
var html = "test";
using (var standardInput = process.StandardInput)
{
standardInput.WriteLine(html);
}
using (var memoryStream = new MemoryStream())
{
using (var baseStream = process.StandardOutput.BaseStream)
{
var buffer = new byte[4096];
int count;
while ((count = baseStream.Read(buffer, 0, buffer.Length)) > 0)
memoryStream.Write(buffer, 0, count);
}
var end = process.StandardError.ReadToEnd();
if (memoryStream.Length == 0L)
throw new Exception(end);
process.WaitForExit();
array = memoryStream.ToArray();
}
Console.WriteLine(array.Length);
}
}
}
but fails in net5.0 with:
System.Exception: QPainter::begin(): Returned false Exit with code 1, due to unknown error.
Configuration
- dotnet --version:
5.0.101 - Ubuntu 20.04.1 LTS
- wkhtmltox_0.12.6-1.bionic_amd64
Regression?
Works in netcoreapp3.1
Other information
related:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 28 (17 by maintainers)
Commits related to this issue
- Add test validating against regression in #46469 — committed to eiriktsarpalis/runtime by eiriktsarpalis 3 years ago
- Add test validating against regression in #46469 — committed to eiriktsarpalis/runtime by eiriktsarpalis 3 years ago
- Add test validating against regression in #46469 — committed to eiriktsarpalis/runtime by eiriktsarpalis 3 years ago
- Add test validating against regression in #46469 (#47643) * Add test validating against regression in #46469 * fix test bug — committed to dotnet/runtime by eiriktsarpalis 3 years ago
- Add test validating against regression in #46469 (#47643) * Add test validating against regression in #46469 * fix test bug — committed to eiriktsarpalis/runtime by eiriktsarpalis 3 years ago
- Revert "Use socketpair to implement Process.Start redirection" (#47461) (#47644) * Revert "Use socketpair to implement Process.Start redirection" (#47461) * Revert #34861 * reinstate removed te... — committed to dotnet/runtime by eiriktsarpalis 3 years ago
cc @adamsitnik @carlossanlop
This is indeed the root cause for the issue.
openfor/dev/stdoutfails when it is asocket.@stephentoub this is a regression caused by changing the
ProcessStreamsfrompipestosockets.