Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for a nullref thrown when PSES calls ForcePSEventHandling #1097

Merged
merged 2 commits into from Oct 30, 2019

Conversation

TylerLeonhardt
Copy link
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
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
Copy link
Member

daxian-dbw commented Oct 16, 2019

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
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.

Copy link
Member

@daxian-dbw daxian-dbw left a comment

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.

@TylerLeonhardt
Copy link
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.

Copy link
Contributor

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM!

@TylerLeonhardt
Copy link
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.

None yet

3 participants