Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cmdrkotori
Copy link
Member

@cmdrkotori cmdrkotori commented Nov 26, 2024

Also flush any pending messages to the log file. Most users on Windows would not see the pending message dump on stderr, and depend on the file to retrieve the log. This may make fatal errors reported by qFatal more complete. However, if the logs are not set to immediate mode and a segfault happens between dumps to disk, messages will still get missed.

Change "Window update interval" to "Update interval" to indicate that it applies across the board. Change update interval suffix from "msec" to "ms". Indicate that "No interval" should be used during testing.

@cmdrkotori
Copy link
Member Author

cmdrkotori commented Nov 26, 2024

I guess if we're feeling brave we can intercept the SIGSEGV signal during the lifetime of the logger and use it to flush pending logging messages in the case that immediate mode is not selected. I really don't want to do this though.

@cmdrkotori cmdrkotori marked this pull request as draft November 26, 2024 13:51
@cmdrkotori
Copy link
Member Author

This still needs some work. Thinking about it, makeLog shouldn't be used as it depends on a queued connection, and so the fatal message wouldn't be queued by the time pending messages are flushed. I'll get to this in the morning.

@tbertels
Copy link
Member

While you're at it, you could rename the logUpdateInterval suffix from msec to ms.

@cmdrkotori cmdrkotori force-pushed the logging_improvements_pending branch from 924dfb4 to ad3cd53 Compare November 26, 2024 23:59
@cmdrkotori
Copy link
Member Author

Fixed. fatalMessage() is now a blocking call to the log thread, the race condition should be no more.

While you're at it, you could rename the logUpdateInterval suffix from msec to ms.

Done.

@cmdrkotori cmdrkotori marked this pull request as ready for review November 27, 2024 00:03
@cmdrkotori cmdrkotori marked this pull request as draft November 27, 2024 00:32
Also flush any pending messages to the log file.  Most users on Windows
would not see the pending message dump on stderr, and depend on the file
to retrieve the log.  This may make fatal errors reported by qFatal more
complete.  However, if the logs are not set to immediate mode and a
segfault happens between dumps to disk, messages will still get missed.

To do this, we reword the qt message handler to file the fatal log
message normally, so that it will get picked up by the final message
dump, for both file and console.  And change the fatalMessage procedure
call into a blocking call on the log thread, so that we aren't trying to
dump pendingMessages while the log thread is writing to it... hopefully
the application is still in a good enough state to do blocking calls.
Because the fatalMessage handler is now in the log thread where it
should be, it can empty the pending message queue so that these messages
won't be written twice before the application quits.
Update translations and ui files with the new string.

It appears that Qt also decided to shuffle some xml nodes around in the
ui file, even though it doesn't change anything.
Use proper SI unit representation for milliseconds.

While I'm here, add note about using no delay for testing.
@cmdrkotori cmdrkotori force-pushed the logging_improvements_pending branch from ad3cd53 to cab1cb6 Compare November 27, 2024 00:36
@cmdrkotori cmdrkotori marked this pull request as ready for review November 27, 2024 00:37
@cmdrkotori
Copy link
Member Author

Ok that should be it for real this time. I thought of a last-minute bug an hour after I've pushed. (the need to empty the pending message queue). Sorry for the mail spam.

@tbertels
Copy link
Member

It works fine with qFatal. 👍

@tbertels tbertels merged commit c5c31d6 into mpc-qt:master Nov 27, 2024
4 checks passed
@tbertels
Copy link
Member

I guess if we're feeling brave we can intercept the SIGSEGV signal during the lifetime of the logger and use it to flush pending logging messages in the case that immediate mode is not selected. I really don't want to do this though.

Do you mean that there would be side effects?

I've written some code to do that and it doesn't seem to affect the stack trace.

tbertels added a commit to tbertels/mpc-qt that referenced this pull request Nov 27, 2024
This ensures all messages get written to the log file on segmentation
fault.
Idea from mpc-qt#278.
@cmdrkotori
Copy link
Member Author

Do you mean that there would be side effects?

I've written some code to do that and it doesn't seem to affect the stack trace.

Well that's good. I thought we might have to think about using libbacktrace to create the traces ourselves.

@tbertels tbertels added the for backporting This pull request should be backported to the latest release label Nov 28, 2024
cmdrkotori pushed a commit to cmdrkotori/mpc-qt-test that referenced this pull request Nov 29, 2024
This ensures all messages get written to the log file on segmentation
fault.
Idea from mpc-qt#278.
@cmdrkotori cmdrkotori mentioned this pull request Nov 29, 2024
@tbertels tbertels added backported This pull request has been backported to the latest release and removed for backporting This pull request should be backported to the latest release labels Nov 29, 2024
@cmdrkotori cmdrkotori deleted the logging_improvements_pending branch July 29, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported This pull request has been backported to the latest release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants