Skip to content

Fix for a nullref thrown when PSES calls ForcePSEventHandling - #1097

Merged
daxian-dbw merged 2 commits into
PowerShell:masterfrom
TylerLeonhardt:fix-for-pses
Oct 30, 2019
Merged

Fix for a nullref thrown when PSES calls ForcePSEventHandling#1097
daxian-dbw merged 2 commits into
PowerShell:masterfrom
TylerLeonhardt:fix-for-pses

Conversation

@TylerLeonhardt

Copy link
Copy Markdown
Member

In PowerShell Editor Services, we have a private contract with PSRL with a method called ForcePSEventHandling found in:

Due to the multi-threaded nature of PSES, we are calling ForcePSEventHanding before the _forceEventWaitHandle was initialized (which happens in DelayedOneTimeInitialize() thus causing a null reference exception.

This PR moves the initialization to the field declaration which fixes the issue we were seeing (PSES crashing).

This should be low risk as this is only used by PSES and they are a private contract.

@TylerLeonhardt

Copy link
Copy Markdown
Member Author

There are some greater questions that can be asked on the overall design of this contract, but this at least mitigates the issue for now.

cc @SeeminglyScience

@daxian-dbw

daxian-dbw commented Oct 16, 2019

Copy link
Copy Markdown
Member

Would changing ForcePSEventHandling to _singleton?._forceEventWaitHandle?.Set(); solve the PSES problem too? (syntax needs to change to compile with 4.6.1 though)

@TylerLeonhardt

Copy link
Copy Markdown
Member Author

Thought about that but we want that _forceEventWaitHandle to be set when we call the method. It probably doesn't make a huge difference, but this PR keeps the idea consistent of "when this method is called, it sets this AutoResetEvent" rather than it being best effort.

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine with this change.

@daxian-dbw
daxian-dbw requested a review from lzybkr October 16, 2019 19:55
@TylerLeonhardt

Copy link
Copy Markdown
Member Author

I consulted heavily with @SeeminglyScience on this - who originally did the ground work. I'd like to give him a chance to sign off so hold off on merging until he gives a thumbs up.

@SeeminglyScience SeeminglyScience left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@TylerLeonhardt

Copy link
Copy Markdown
Member Author

I don't see a problem with that, @daxian-dbw 👍 LGTM

@daxian-dbw
daxian-dbw merged commit 65be868 into PowerShell:master Oct 30, 2019
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.

3 participants