Skip to content

Mitigate stack overflow issue#6224

Merged
JohnMcPMS merged 2 commits into
microsoft:masterfrom
JohnMcPMS:stack-shrink
May 13, 2026
Merged

Mitigate stack overflow issue#6224
JohnMcPMS merged 2 commits into
microsoft:masterfrom
JohnMcPMS:stack-shrink

Conversation

@JohnMcPMS
Copy link
Copy Markdown
Member

@JohnMcPMS JohnMcPMS commented May 12, 2026

📖 Description

We see some very rare crashes where the stack is too small to support the WIL message formatting of THROW_HR_MSG. This change attempts to mitigate that through a few targeted reductions in stack usage (doesn't get a lot but these were the only high ROI locations found) and by probing the remaining stack to decide whether to include the exception message or not on the throw.

🔗 References

None.

🔍 Validation

Manual run with forced error still includes the exception message.

Microsoft Reviewers: Open in CodeFlow

…choice to include message based on stack size in rethrow
@JohnMcPMS JohnMcPMS requested a review from a team as a code owner May 12, 2026 22:38
yao-msft
yao-msft previously approved these changes May 12, 2026
Comment thread src/AppInstallerSharedLib/Runtime.cpp Outdated
ULONG_PTR low, high;
GetCurrentThreadStackLimits(&low, &high);
auto remaining = reinterpret_cast<ULONG_PTR>(&low) - low;
if (remaining > high - low) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (remaining > high - low) {
if (remaining > high - low)
{

nit

@JohnMcPMS JohnMcPMS merged commit 86e3790 into microsoft:master May 13, 2026
9 checks passed
@JohnMcPMS JohnMcPMS deleted the stack-shrink branch May 13, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants