web-view icon indicating copy to clipboard operation
web-view copied to clipboard

Segfault when running any example with Edge

Open green-s opened this issue 6 years ago • 10 comments
trafficstars

When running any of the examples with the edge feature enabled I'm getting an access violation (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN).

ucrtbase.dll!abort()
ucrtbase.dll!terminate()
dialog.exe!`winrt::to_hresult'::`1'::catch$5() Line 4599
	at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(4599)
vcruntime140_1.dll!_CallSettingFrame_LookupContinuationIndex()
vcruntime140_1.dll!__FrameHandler4::CxxCallCatchBlock(struct _EXCEPTION_RECORD *)
ntdll.dll!RcConsolidateFrames()
dialog.exe!winrt::to_hresult() Line 4574
	at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(4574)
dialog.exe!`winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Web::UI::IWebViewControl,winrt::Windows::Web::UI::WebViewControlNavigationStartingEventArgs>>::type<<lambda_04b02dc4d8258bdef020ee9648caadb1>>::Invoke'::`1'::catch$0() Line 9017
	at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(9017)
vcruntime140_1.dll!_CallSettingFrame_LookupContinuationIndex()
vcruntime140_1.dll!__FrameHandler4::CxxCallCatchBlock(struct _EXCEPTION_RECORD *)
ntdll.dll!RcConsolidateFrames()
dialog.exe!winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Web::UI::IWebViewControl,winrt::Windows::Web::UI::WebViewControlNavigationStartingEventArgs>>::type<<lambda_04b02dc4d8258bdef020ee9648caadb1>>::Invoke(void * sender=0x0000021e6c392c80, void * args=0x0000021e6c392a00) Line 9015
	at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(9015)
EdgeManager.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<<lambda_6c3a5ff7cf338864a8a9147abc6a0185>,Windows::Foundation::ITypedEventHandler<WebRuntime::Diagnostics::DiagnosticsTarget * __ptr64,WebRuntime::Diagnostics::IDiagnosticsMessageReceivedEventArgs * __ptr64>>()
EdgeManager.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Core::CoreWindowSite *,class Windows::UI::Core::NavigationFocusEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::InvokeAll<struct Windows::UI::Core::ICoreWindowSite *,struct Windows::UI::Core::INavigationFocusEventArgs *>(struct Windows::UI::Core::ICoreWindowSite *,struct Windows::UI::Core::INavigationFocusEventArgs *)
EdgeManager.dll!Windows::Web::UI::WebViewControlBase::OnCoreWebViewNavigationStarting(struct ICoreWebViewPrivate *,struct CoreWebViewNavigationStartingEventDetails *,int *)
EdgeManager.dll!CCoreWebViewControl::CanNavigate(unsigned short *,long &)
EdgeManager.dll!CCoreWebViewControl::NavigateToStringInternal(unsigned short *)
EdgeManager.dll!CCoreWebViewControl::NavigateToString(unsigned short *)
EdgeManager.dll!Windows::Web::UI::WebViewControlBase::NavigateToString(struct HSTRING__ *)
dialog.exe!winrt::impl::consume_Windows_Web_UI_IWebViewControl<winrt::Windows::Web::UI::IWebViewControl>::NavigateToString(const winrt::param::hstring & text={...}) Line 116
	at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\Windows.Web.UI.h(116)
dialog.exe!webview::webview::navigate(const char * url=0x0000021e69c1eb90) Line 628
	at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.h(628)
dialog.exe!webview_navigate(void * w=0x0000021e69c1ce50, const char * url=0x0000021e69c1eb90) Line 714
	at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.h(714)
dialog.exe!wrapper_webview_new(const char * title=0x0000021e69c27f50, const char * url=0x0000021e69c1eb90, int width=800, int height=600, int resizable=1, int debug=1, void(*)(void *, const char *) external_invoke_cb=0x00007ff6e7d03ba0, void * userdata=0x0000021e69c29bf0) Line 15
	at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.cc(15)
dialog.exe!web_view::WebView<()>::new<(),closure-0>(std::ffi::c_str::CStr * title=0x0000021e69c27f50, int url, int width, bool height=600, bool resizable=true, ..., dialog::main::closure-0 debug=true) Line 290
	at C:\Users\samgr\src\web-view-rs\src\lib.rs(290)
dialog.exe!web_view::WebViewBuilder<(), closure-0, str*>::build<(),closure-0,str*>(web_view::WebViewBuilder<(), closure-0, str*> self) Line 214
	at C:\Users\samgr\src\web-view-rs\src\lib.rs(214)
dialog.exe!dialog::main() Line 8
	at C:\Users\samgr\src\web-view-rs\examples\dialog.rs(8)

Minidump

green-s avatar Sep 30 '19 06:09 green-s

I'll try to reproduce this.

richardhozak avatar Sep 30 '19 08:09 richardhozak

So I looked a bit into this, first i thought maybe it was an older sdk, but you have the same version as me 10.0.18362.0. I remember I had problems with with compiler from MSVC 2017, could you try installing 2019 Build Tools (no need for the whole Visual Studio) and try if it fixes the issue?

richardhozak avatar Oct 03 '19 19:10 richardhozak

I already have Visual Studio 2019 installed and as far as I know I'm using the latest build tools. I tried building from the "Developer Command Prompt for VS 2019" and "x64 Native Tools Command Prompt for VS 2019", with no difference. Did you see something that indicates that I'm using MSVC 2017?

green-s avatar Oct 05 '19 22:10 green-s

Did you see something that indicates that I'm using MSVC 2017?

No it's just that I remember having problems with that. I cannot reproduce this yet, I'll try again when I have more energy to delve deeper.

richardhozak avatar Oct 08 '19 18:10 richardhozak

I have the same problem, with everything installed as suggested in the readme. EDIT: I've experienced the issue on my laptop, but not my desktop PC. Both are on windows 10.

FrankenApps avatar Feb 05 '20 18:02 FrankenApps

I have a very similar problem, possible related but not exactly the same stack. The webview starts and closes almost instantly without any information, when debugging with visual studio, it is clear that there is an exception internal to webview-sys navigate function.

    void navigate(const char* url)
    {
        std::string html = html_from_uri(url);
        if (html != "") {
            m_webview.NavigateToString(winrt::to_hstring(html.c_str()));
        } else {
            Uri uri(winrt::to_hstring(url));
            m_webview.Navigate(uri);  <------ HERE
        }
    }

Then further down windows sdk will try to convert the exception using to_hresult(), which in turn calls a std::terminate(). I'll missed which was the exception, I'll try to collect more info once I'm at the problematic machine.

Windows SDK 10.0.18362.0

fungos avatar Feb 13 '20 23:02 fungos

Hey, I experienced the issue myself when trying to load a local file using the edge feature. In particular:

  • Everything works correctly when loading a remote url, such as https://google.com
  • When I try to open a local file using the file: uri prefix, the same crash happens.

Steps to reproduce:

  1. Create a local file index.html with the following content:
<html lang="en">
<head>
    <title>Hello</title>   
</head>

<body>
    Hello
</body>

</html>
  1. Load the file using the File URI path:
 web_view::builder()
        .title("My Project")
        .content(Content::Url("file:///C:/Users/Freddy/Documents/testgui/index.html"))
        .size(700, 480)
        .resizable(true)
        .user_data(())
        .invoke_handler(|_webview, _arg| Ok(()))
        .run()
        .unwrap();

The script will crash with exit code: (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

I'll try to dig myself into the code to find the root of the issue.

I'm running Visual Studio 2019

Cheers

federico-terzi avatar Mar 23 '20 11:03 federico-terzi

Following up to my previous comment, it turns out my use case (loading a file using the file:// protocol uri) is not currently possible. See https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/2211

federico-terzi avatar Mar 23 '20 22:03 federico-terzi

Hopefully this will be fixed, when we switch to Edge Preview, I am working on it.

richardhozak avatar Mar 24 '20 08:03 richardhozak

Glad to hear that @zxey, thanks for your reply

federico-terzi avatar Mar 24 '20 11:03 federico-terzi