-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: Missing --help output & other diagnostic messages in console #1822
Conversation
This effectively reverts 7c1e33d, which was partially reverted only on Windows by code that was left commented out in f114239. Allowing other libraries to print to stderr may make the output ‘ugly’, but lots of things print to stderr that are important for figuring out why something is bugged, like ASan and glib.
The reason why I turned these off was because libmagic just spammed hundreds of lines of bogus log messages to stderr without any way to turn it off. That's just really terrible and outdated library design. I'd argue that we should keep this for the sake of usability of the logs and instead only disable stderr in release builds where you won't be using diagnostics tools or asserts anyways. |
Do you know where in libmagic this is happening, or how I could trigger it? Looking at the source code it seems like debugging output is gated behind |
When loading compiled magic files or compiling some magic source files, it would spew out hundreds of warning / error logs to the console. |
Oops. I see
There are a couple of other places where messages look like they are unconditionally emitted via To me it seems like the thing to do for libmagic specifically could be to temporarily redirect stderr to collect the emitted warnings while it is running rather than suppressing all stderr output globally. Presumably if someone is using a custom magic file and there is some syntax error it would be helpful for them to see that; getting a single error from
|
Hm that flag should definitely be removed. But since it still doesn't silent all errors it's not really a full solution. Personally, I just believe that some random system library has no right to dump a bunch of crap into my program. That log output is not integrated into the whole logging system at all so first of all it doesn't even show up in the in-app log console and second it's generally not helpful to the end user. People aren't using ImHex to debug or write magic files normally. What I find weird though is why --help doesn't show up in the console for you. It definitely does for me and it uses the default logging mechanism through stdout to print its output, ImHex never uses stderr |
I agree that libmagic seems like a mess of a thing that probably started its life as an executable and only got half-abstracted out into a library. I am no fan of C—especially error handling in C libraries, which is almost universally awful—and also agree that in an ideal world things would not be this way. Unfortunately, the standard mechanism for emitting most diagnostic information today is still just writing to What benefit is there to users to suppress What harm is there to users to suppress As far as why Originally, ImHex was crashing due to a memory error, and glibc was emitting a diagnostic, but ImHex was suppressing it. I occasionally have three brain cells to rub together and eventually ran So, these are my thoughts. Maybe you have a different idea about which things are most important and that’s fine, do whatever you think is best. This did cause me to waste time and energy and I like to try to make it so others don’t have to waste time and energy too. |
Probably neither here nor there at this point but vscode’s built-in terminal does seem to do something weird with file descriptors that other terminals don’t that seems to be able to cause applications to break. I tried to run flatpak wine inside of a vscode terminal, which works fine in a normal terminal, but hangs with 100% CPU forever in vscode. strace shows |
Problem description
Typing
--help
causes ImHex to exit without outputting anything. Diagnostic messages from glib, ASan, other libraries that might have something important to say, etc. are also suppressed.Implementation description
This effectively reverts 7c1e33d, which was partially reverted only on Windows by code that was left commented out in f114239.
Allowing other libraries to print to stderr may make the output ‘ugly’, but lots of things print to stderr that are important for figuring out why something is bugged, like ASan and glib.
Additional things