MicrosoftEdge / MicrosoftEdge/WebView2Feedback

ICoreWebView2WebResourceRequest get_Content passes back a stream object with invalid pointer to Read method

Open
#2,294 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
Our Win32 app uses WebView2 to display some web pages and inspect the GET and POST requests sent while the page is loading etc. In our Invoke function we attempt to read the POST request data, like this:

	HRESULT STDMETHODCALLTYPE
	Invoke (ICoreWebView2* webview, ICoreWebView2WebResourceRequestedEventArgs* args)
	{
		ICoreWebView2WebResourceRequest* req;
		IStream* strm;
		HRESULT hr;

		hr = args->get_Request(&req);
		if (SUCCEEDED(hr)) {
			hr = req->get_Content(&strm);
			if (SUCCEEDED(hr)) {
				char *data = (char *)HeapAlloc(GetProcessHeap(), 0, 32768);
				if (data != NULL) {
					DWORD actcount = 0;
					hr = strm->Read(data, 32768, &actcount);
					if (hr == S_OK || hr == S_FALSE) {
						/* do stuff with data */
					}
					HeapFree(GetProcessHeap(), 0, data);
				}
			}
		}
		return(S_OK);
	}

the code above will in some cases fail when calling strm->Read(...) with the following:

Exception thrown: read access violation.
ISequentialStream::Read[virtual] was 0xFFFFFFFFFFFFFFFF.

OR

Exception thrown: read access violation.
strm->lpVtbl+1->QueryInterface was 0xFFFFFFFFFFFFFFFF.

Version
SDK: Windows 10 SDK 10.0.20348.0
Runtime: Microsoft.Web.WebView2 1.0.1054.31 and 1.0.1150.38
Framework: Win32
OS: Windows Server 2019 (17763.2686)

AB#38652932

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Win32 Invoke example in the issue and reproduce the failure at IStream::Read after ICoreWebView2WebResourceRequest::get_Content. Compare behavior across the listed WebView2 SDK and runtime versions, and inspect whether the returned stream pointer remains valid. Done means identifying a reliable cause and documenting or resolving the invalid pointer behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.