-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add size message checks for logging #45892
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
Add size message checks for logging #45892
Conversation
EWS run on previous version of this PR (hash 90e7561) |
90e7561
to
303cb0f
Compare
EWS run on previous version of this PR (hash 303cb0f) |
if (type == OS_LOG_TYPE_FAULT) | ||
type = OS_LOG_TYPE_ERROR; | ||
|
||
if (char* messageString = os_log_copy_message_string(msg)) { | ||
auto logString = unsafeSpan8IncludingNullTerminator(messageString); | ||
WebProcess::singleton().sendLogOnStream(logChannel, logCategory, logString, type); | ||
if (logString.size() < logStringMaxSize) | ||
WebProcess::singleton().sendLogOnStream(logChannel, logCategory, logString, type); |
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.
Could this affect WebRTC logging which can be quite long (but quite useful for debugging)?
Also, if a channel log is debug, I would expect logging to be high in general.
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.
That is a good point! Is there WebRTC logging in the WebContent process? If so, would you know the approximate size of the largest log string?
Thanks for reviewing!
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.
In the latest patch, I increased the max size of the log string to accommodate for this.
303cb0f
to
6330177
Compare
EWS run on previous version of this PR (hash 6330177) |
if (type == OS_LOG_TYPE_FAULT) | ||
type = OS_LOG_TYPE_ERROR; | ||
|
||
if (char* messageString = os_log_copy_message_string(msg)) { | ||
auto logString = unsafeSpan8IncludingNullTerminator(messageString); | ||
WebProcess::singleton().sendLogOnStream(logChannel, logCategory, logString, type); | ||
if (logString.size() < logStringMaxSize) |
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.
Should we truncate the string and send instead of dropping message?
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.
That is a good point, will fix!
Thanks for reviewing!
6330177
to
cde89e0
Compare
EWS run on previous version of this PR (hash cde89e0) |
String logStringTruncated = String::fromUTF8(logString).left(logStringMaxSize - 1); | ||
logString = byteCast<uint8_t>(logStringTruncated.utf8().spanIncludingNullTerminator()); | ||
WebProcess::singleton().sendLogOnStream(logChannel, logCategory, logString, type); | ||
} else |
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.
Maybe we could move WebProcess::singleton().sendLogOnStream(
out of if
condition and remove else
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.
That is a good point, will fix.
Thanks for reviewing!
cde89e0
to
5cb177a
Compare
EWS run on previous version of this PR (hash 5cb177a) |
9898373
to
63eb21a
Compare
EWS run on current version of this PR (hash 63eb21a) |
https://bugs.webkit.org/show_bug.cgi?id=293558 rdar://152010794 Reviewed by Sihui Liu. * Source/WebKit/Shared/LogStream.cpp: (WebKit::LogStream::logOnBehalfOfWebContent): * Source/WebKit/Shared/LogStream.h: * Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::registerLogHook): Canonical link: https://commits.webkit.org/296808@main
63eb21a
to
3a08604
Compare
Committed 296808@main (3a08604): https://commits.webkit.org/296808@main Reviewed commits have been landed. Closing PR #45892 and removing active labels. |
3a08604
63eb21a