Repository navigation
Make sure that message structures are correctly zero-initialized - #41373
Merged
Merged
Conversation
Several message structures were declared without value-initialization
before their fields were assigned. Use {} consistently at the
declaration so the structures start out zeroed.
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make message structs used in WSL’s init/mini_init and WSLC channel transactions start from a known-zero state by adding {} at declaration sites, reducing the risk of sending indeterminate data when not all fields are explicitly assigned.
Changes:
- Added
{}value-initialization to several WSLC message instances before fields are populated and sent. - Added
{}value-initialization to init/mini_init message structs on both Windows and Linux paths. - Applied the same pattern in interop paths where exit-status messages are constructed and sent.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/wslcsession/WSLCVirtualMachine.cpp | Value-initialize several WSLC request messages before populating fields and calling Transaction(). |
| src/windows/wslcsession/DockerHTTPClient.cpp | Value-initialize WSLC_FORK before sending the fork request over the channel. |
| src/windows/service/exe/WslCoreVm.cpp | Value-initialize mini_init message structs prior to setting header/payload fields. |
| src/windows/common/interop.cpp | Value-initialize LX_INIT_PROCESS_EXIT_STATUS prior to setting header/payload fields. |
| src/linux/init/util.cpp | Value-initialize MESSAGE_HEADER before setting message type/size for queries. |
| src/linux/init/main.cpp | Value-initialize LX_MINI_INIT_MOUNT_RESULT_MESSAGE prior to setting header/result fields. |
| src/linux/init/init.cpp | Value-initialize session/exit-status response structs before setting fields. |
| src/linux/init/drvfs.cpp | Value-initialize MESSAGE_HEADER for the drvfs elevated query message. |
| src/linux/init/binfmt.cpp | Value-initialize reply/resize structs before use (including a local aggregate Reply). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The WSLC_* message types declare a default constructor via DECLARE_MESSAGE_CTOR, so adding {} at the declaration has no effect for them. Limit the change to the aggregate message types, where {} actually initializes the structure.
Co-authored-by: Copilot <[email protected]>
Blue (OneBlue)
approved these changes
Aug 18, 2026
Ben Hillis (benhillis)
enabled auto-merge (squash)
August 18, 2026 21:31
Ben Hillis (benhillis)
added a commit
that referenced
this pull request
Sep 9, 2026
) (#41524) * Make sure that message structures are correctly zero-initialized Several message structures were declared without value-initialization before their fields were assigned. Use {} consistently at the declaration so the structures start out zeroed. Co-authored-by: Copilot <[email protected]> * Drop redundant initializers from WSLC message declarations The WSLC_* message types declare a default constructor via DECLARE_MESSAGE_CTOR, so adding {} at the declaration has no effect for them. Limit the change to the aggregate message types, where {} actually initializes the structure. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Ben Hillis <[email protected]> Co-authored-by: Copilot <[email protected]> (cherry picked from commit 5106ffe) Copilot-Session: 35c940dc-b8de-495b-b9c6-b33f4fa16030
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Several message structures were declared without value-initialization before their fields were assigned, so any field not explicitly set (and any padding, for the aggregate types) started out indeterminate rather than zeroed.
This adds
{}at the declaration so the structures are consistently zero-initialized before use, matching the pattern already used elsewhere (e.g.LX_INIT_CREATE_PROCESS_RESPONSEininterop.cppandLX_INIT_WINDOW_SIZE_CHANGEDinsvccomm.cpp).No behavioral change is intended; every field that was previously assigned is still assigned.