-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Enforce 64KB event payload size limit on EventPipe #50600
Conversation
@@ -897,6 +897,9 @@ ep_buffer_manager_write_event ( | |||
// Before we pick a buffer, make sure the event is enabled. | |||
ep_return_false_if_nok (ep_event_is_enabled (ep_event)); | |||
|
|||
// Check that the payload size is less than 64 KB (max size for ETW events) | |||
ep_return_false_if_nok (ep_event_payload_get_size (payload) <= 64 * 1024); |
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.
ETW might limit its payloads to 64KB, but does EventPipe need to? EventSource
doesn't explicitly prevent you from having payloads this large, e.g., your test.
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.
It doesn't. But ETW will drop the event if it's greater than 64KB and I'd like to enforce the same behavior here since:
- We need some kind of limit regardless. Currently >100KB payloads crash the app. We could enforce a 100KB limit instead of 64KB.
- But if we do enforce 100KB limit, that leads to a discrepancy between ETW/EventPipe behavior which we then need to go and figure out how customers can find out whether big events are getting dropped on ETW but not on EventPipe and document why such behavior differences exist.
- Another approach is to enforce 1MB payload (which we currently do - just not explicitly but because we just fail to allocate buffers greater than that) and increase the max flushing block size to 1MB but that's a pretty inefficient use of space for sessions listening on much smaller-sized payloads (i.e. counters).
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.
Fair point. Let me mull this over, but I think 64KB is fine. Should we remove the DebugBreak
in the EP_UNLIKELY
macro expansion?
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.
I'd actually like to keep that. It lets us catch exceptions like this rather than silently failing and us never noticing the failures.
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.
A few comments inline, looks good otherwise : )
I'm merging this since CI failure is due to #50753. |
…shim_mono # By Aaron Robinson (10) and others # Via GitHub * upstream/main: (108 commits) [mbr] Add Apple sample (dotnet#50740) make EstablishProxyTunnelAsync throw on failure status code from proxy (dotnet#50763) Improve RGB Min Max evaluation performance by using 2 or 3 comparison… (dotnet#50622) [mono] More domain cleanups (dotnet#50479) Fix Crossgen2 of PlatformDefaultMemberFunction methods and calls. (dotnet#50754) Disable EventSource generator in design-time builds (dotnet#50741) Fix X509 test failures on Android (dotnet#50301) Do not confuse fgDispBasicBlocks in fgMorphBlocks (dotnet#50703) Enforce 64KB event payload size limit on EventPipe (dotnet#50600) Reorganize CoreCLR native build to reduce CMake reconfigures when the build system is untouched (dotnet#49906) [mbr] Turn on hot reload for iOS, tvOS and MacCatalyst (dotnet#50458) improve connection scavenge logic by doing zero-byte read (dotnet#50545) Resolve call mdtokens when making tier 1 inline observations (dotnet#50675) Annotate APIs in System.Private.Xml (dotnet#49682) Support compiling against OpenSSL 3 headers Change Configuration.Json to use a regular Dictionary. (dotnet#50611) Remove unused BigNumFromBinary P/Invoke (dotnet#50670) Make Ninja the default CMake generator on Windows for the repo (dotnet#49715) [AppleAppBuilder] Entitlements to run tests on catalyst using the JIT (dotnet#50637) [mono] Fix delegate invokes to dynamic methods in mixed mode. (dotnet#50547) ... # Conflicts: # src/mono/dlls/mscordbi/CMakeLists.txt
ETW has a maximum of 64KB event payload size limit that is not enforced on EventPipe. This causes issues like #50515 to occur where an event that's greater than 100KB can cause the flushing thread's event block to be too small to fit a single event payload, which crashes the application.