New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libhb/gtk: do not modify stderr struct directly on mingw #5945
base: master
Are you sure you want to change the base?
Conversation
Thanks for this. Where are you getting your mingw-w64 toolchain from, Fedora or the included build script, somewhere else? |
Official Fedora packages: https://docs.fedoraproject.org/en-US/packaging-guidelines/MinGW/ |
I'm afraid this doesn't work. We get no output on this in Windows. |
Sorry for not testing it. I was only compiling the CLI version and assumed it was working being there in the GTK code. Found this: https://stackoverflow.com/a/25927081 This freopen("NUL", "w", stderr);
_dup2(pfd[1], _fileno(stderr)); works on both ucrt and msvcrt here. @sr55 please give it a try. |
7aec87e
to
8376af5
Compare
(I did not test the GTK part) |
The mingw port of the gtk gui rarely gets tested as far as I know. I did the port just for kicks and then pretty much set it aside. It's probably full of bit-rot. |
With UCRT, all logging before the redirection is lost ("Compile-time hardening features are enabled" for example). It does not occur with MSVCRT somehow. |
Looks good, tested on Windows and it looks fine. |
stderr->_file = pfd[1]; | ||
// Non-console windows apps do not have a stderr->_file | ||
// assigned properly | ||
(void) freopen("NUL", "w", stderr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, does this leave a file named "NUL" somewhere that needs to be cleaned up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
But since this affects Windows, I'll let @sr55 make the final decision to merge
Sorry for the delayed response. Looks like this is still causing a regression on Windows. We are losing some (not all) log messages now, rather than them being completely missing. As if a buffer is not being flushed correctly. Note, the After on the right is missing a bunch of logging that only later appears once the encode finalises. |
Breaks mingw build when using UCRT: ../libhb/hb.c: In function 'redirect_thread_func': ../libhb/hb.c:2314:11: error: 'FILE' {aka 'struct _iobuf'} has no member named '_file' 2314 | stderr->_file = pfd[1]; | ^~ See: mingw-w64/mingw-w64@fe226dd
Let's try |
Note: |
That appears to behave better. |
Breaks mingw build when using UCRT:
See:
mingw-w64/mingw-w64@fe226dd
Implement the same approach used by the GTK UI code:
HandBrake/gtk/src/application.c
Lines 307 to 311 in 3a9e37d
Tested on: