Skip to content
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

Handle sessionId as ulong instead of long in EventPipeSession.cs. #4345

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

lateralusX
Copy link
Member

@lateralusX lateralusX commented Oct 20, 2023

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.

@lateralusX
Copy link
Member Author

lateralusX commented Oct 20, 2023

@mdh1418 Possible to take this fix on a test drive on your local debug build where you hit the assert when running against physical Android device?

@mdh1418
Copy link
Member

mdh1418 commented Oct 23, 2023

Testing this locally, I no longer hit the Debug.Assert(_sessionId > 0); that I was hitting previously.

@lateralusX lateralusX force-pushed the lateralusX/fix-session-id-parsing branch from 1e6500b to f66df56 Compare October 23, 2023 15:54
@lateralusX lateralusX marked this pull request as ready for review October 23, 2023 17:17
@lateralusX lateralusX requested a review from a team as a code owner October 23, 2023 17:17
@mikem8361
Copy link
Member

Can someone review this? I want to snap the sources with this PR for the tools release.

@hoyosjs hoyosjs merged commit 6f9f639 into dotnet:main Oct 23, 2023
20 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants