Skip to content

Stop crashing hh.exe when passing strings to MSHTML - #9052

Merged
michaelDCurran merged 2 commits into
rcfrom
i8976
Dec 12, 2018
Merged

Stop crashing hh.exe when passing strings to MSHTML#9052
michaelDCurran merged 2 commits into
rcfrom
i8976

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Aiming for 2018.4rc2 as this is a crash.

Link to issue number:

Closes #8976

Summary of the issue:

Similar to issue #8759 where Firefox was crashing when passing a string literal to a COM method, hh.exe when opening particular chm files would also crash.
Again, we are passing a string literal to a COM method, this time in the MSHTML vbufBackend.
Passing a string literal in place of a bstr is bad as the COM marshaller tries to look for the bstr prefix containing the length, and either causes a memory violation or finds junk.
This only however seems to cause a crash in optimized builds of NVDA, and only with very recent versions of Visual Studio 2017, as this particular crash has not been seen before beta1 of 2018.4.

Description of how this pull request fixes the issue:

Similar to pr #8767, the string literal is first converted to a BSTR before passing to the COM method.
This PR also adds a rule to the appveyor config that allows us us to build optimized try builds when a branch name starts with try-release-. This change made it easier to test this fix.

Testing performed:

While running an optimized try build for this pr, opened the chm in issue #8759 and it did not crash.
Also opened several pages in Internet Explorer to ensure that generally NVDA was still getting all required information from MSHTML.
Try build has been provided on the issue, awaiting testing by original reporter.

Known issues with pull request:

None.

Change log entry:

None.

… sure to pass in the attribute name as a bstr as the COM method expects, otherwise the document host process can crash.
// #8976: the string in the following macro must be passed to the COM method as a BSTR
// otherwise the COM marshaller will try and read the BSTR length and hit either inaccessible memory or get back junk.
// This is seen in optimized builds of NVDA when accessing some CHM files in hh.exe.
#define macro_addHTMLAttributeToMap(attribName,allowEmpty,attribsObj,attribsMap,tempVar,tempAttrObj) {\

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.

I guess this has probably been a macro for a while. I'd be quite tempted to turn it into a regular function, the benefits of doing so is to make them more easy to debug, and to get rid of the backslashes.

// This is seen in optimized builds of NVDA when accessing some CHM files in hh.exe.
#define macro_addHTMLAttributeToMap(attribName,allowEmpty,attribsObj,attribsMap,tempVar,tempAttrObj) {\
attribsObj->getNamedItem(attribName,&tempAttrObj);\
attribsObj->getNamedItem(CComBSTR(attribName),&tempAttrObj);\

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.

Is there anything we can do to look for other places this bug might exist?

@LeonarddeR

LeonarddeR commented Dec 12, 2018

Copy link
Copy Markdown
Collaborator

This pr is filed against master. I also found out that the rc branch still seems to be at 2018.3.2.

I think that the rc branch has to be updated based on the 2018.4-rc1 tag, and then we can switch branches for this pr.

@michaelDCurran
michaelDCurran changed the base branch from master to rc December 12, 2018 09:21
@michaelDCurran

michaelDCurran commented Dec 12, 2018 via email

Copy link
Copy Markdown
Member Author

@michaelDCurran
michaelDCurran merged commit 12fc30a into rc Dec 12, 2018
@nvaccessAuto nvaccessAuto added this to the 2018.4 milestone Dec 12, 2018
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.

4 participants