Handle sessionId as ulong instead of long in EventPipeSession.cs. #4345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Session id is a uint64 in runtime as well as specified as a uint64 in IPC protocol, https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md#returns-as-an-ipc-message-payload.
EventPipeSession.cs however handled it as a long instead of an ulong, currently that doesn't affect release builds since it doesn't do much with the id except passing it back to stop the session, but in debug builds there is an assert that validates that session id > 0. On Android physical devices it is not uncommon to get code and memory allocated at high addresses, including having the high order bit set and when that happens, EventPipeSession.cs will see a negative session id and assert on debug builds.
Fix adjust session id as ulong inline with IPC protocol, it also makes sure keyword serialized when starting a session is handled according to IPC specification, but only when serialized into the payload, it will still be typed as long inside EventPipeProvider since it is a public property.