STATUS_STACK_BUFFER_OVERRUN crash on Application::Start with inappropriate SUBSYSTEM
See original GitHub issueDescribe the bug
STATUS_STACK_BUFFER_OVERRUN crash on Application::Start with inappropriate linker option SUBSYSTEM
.
Steps to reproduce the bug
Steps to reproduce the behavior:
- Create a Windows Console Application (C++/WinRT)
- Write the following code in
main.cpp
#include "pch.h"
#include <windows.h>
#include <winrt/Windows.UI.Xaml.h>
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
int main() {
winrt::init_apartment();
Application::Start([](auto&&) {});
return 0;
}
- Build and run the program
- The exit code is
-1073740791
, which is0xc0000409, STATUS_STACK_BUFFER_OVERRUN
- Go to project property, linker, system, set
subsystem
to/SUBSYSTEM:WINDOWS
- Write the following code in
main.cpp
#include "pch.h"
#include <windows.h>
#include <winrt/Windows.UI.Xaml.h>
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
winrt::init_apartment();
Application::Start([](auto&&) {});
return 0;
}
- Build and run the program
- The exit code is no more
-1073740791
Expected behavior
Throw a user-friendly error like APPMODEL_ERROR_NO_PACKAGE
.
Screenshots
Version Info OS version: 1903 (build 18362.836)
NuGet package version: Microsoft.Windows.CppWinRT 2.0.200602.3 (Also reproducible with winrt-rs 0.7)
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | Yes |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Mobile | |
Xbox | |
Surface Hub | |
IoT |
Additional context I understand this is a rare scenario that nobody would do, but STATUS_STACK_BUFFER_OVERRUN does not make sense anyway.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hadn’t thought of that scenario, it’s an interesting one. I usually think of GUI and console apps as two separate universes.
Thanks for bringing that one up, I’ll reactivate this issue and leave it on the backlog, but it’s low-priority at this time.
This was first reported here: https://github.com/microsoft/winrt-rs/issues/214
The issue is that Xaml must report the invalid use of its API as a WinRT error so that languages with strong safety guarantees (like Rust) can make use of Xaml APIs.
Here is a minimal repro. The following C++/WinRT code should not crash but instead report some error message:
Instead, this code causes a failfast: