Fix CreateInstance failure when Windows hosts file exceeds message size cap#40718
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses WSL CreateInstance failures on Windows 10 when DNS tunneling is unavailable and the Windows hosts file content is embedded into the init configuration message. It avoids sending oversized hosts content and increases the socket receive-side message size cap to reduce unexpected failures.
Changes:
- Skip embedding the Windows hosts file content when the parsed payload exceeds 1 MiB, emitting a user warning instead.
- Increase the socket message size safety cap from 4 MiB to 16 MiB in both the shared and Windows receive paths.
- Add a new localized user-warning string describing the oversized-hosts behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/windows/common/HandleIO.cpp | Raises the Windows socket receive message-size limit to 16 MiB. |
| src/windows/common/filesystem.cpp | Adds a 1 MiB guard for parsed Windows hosts content and emits a user warning when exceeded. |
| src/shared/inc/socketshared.h | Raises the shared receive message-size limit to 16 MiB for host/guest communication. |
| localization/strings/en-US/Resources.resw | Introduces a new user-facing warning message about oversized hosts files. |
8604539 to
4e0b744
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/shared/inc/socketshared.h:74
- The protocol max message size (16 MiB) is now hard-coded here and separately in src/windows/common/HandleIO.cpp. Since both are enforcing the same safety cap for the same message header field, keeping the limit as a shared constant would reduce the risk of future drift (e.g., one side updated but not the other).
if (MessageSize > 16 * 1024 * 1024) // 16 MiB
{
#if defined(_MSC_VER)
THROW_HR_MSG(E_UNEXPECTED, "Message size too large: %llu", MessageSize);
#elif defined(__GNUC__)
THROW_UNEXPECTED();
#endif
}
OneBlue
previously approved these changes
Jun 5, 2026
6d7d053 to
311f7c3
Compare
…ze cap On Windows 10 where DNS tunneling is unavailable, the hosts file content is embedded in the configuration message sent to the guest init. If the hosts file exceeds the message size safety check (added in 2.7.x), the guest rejects it causing E_UNEXPECTED. Fix by: - Skipping the hosts file content if it exceeds 8MB, with a user warning - Bumping the message size cap from 4MB to 16MB as additional headroom Fixes #40696 Fixes #40700 Fixes #40699 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
311f7c3 to
8eb1de1
Compare
OneBlue
approved these changes
Jun 5, 2026
benhillis
added a commit
that referenced
this pull request
Jun 6, 2026
…ze cap (#40718) (#40726) On Windows 10 where DNS tunneling is unavailable, the hosts file content is embedded in the configuration message sent to the guest init. If the hosts file exceeds the message size safety check (added in 2.7.x), the guest rejects it causing E_UNEXPECTED. Fix by: - Skipping the hosts file content if it exceeds 8MB, with a user warning - Bumping the message size cap from 4MB to 16MB as additional headroom Fixes #40696 Fixes #40700 Fixes #40699 Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
On Windows 10 where DNS tunneling is unavailable, the Windows hosts file content is embedded in the configuration message sent to the guest init. If the parsed hosts file exceeds 4MB (e.g. ad-blocker hosts lists), the guest rejects it with the message size safety check added in 2.7.x, causing Wsl/Service/CreateInstance/E_UNEXPECTED.
Changes
Why this only affects Win10
On Win11, DNS tunneling is enabled by default so the hosts file is never embedded in the config message. On Win10 19044, the DNS tunneling APIs don't exist (ERROR_PROC_NOT_FOUND), so the code falls back to embedding the full hosts file.
Validation
Fixes #40696
Fixes #40700
Fixes #40699