Skip to content

Fix PowerShell class definition leaking into another Runspace - #11273

Merged
Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:leak
Dec 11, 2019
Merged

Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:leak

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Dec 5, 2019 •

Copy link
Copy Markdown
Member

PR Summary

Fix #9313

The root problem is that a scope is holding on the shared default TypeResolutionState object when there is no PowerShell class defined in the parent chain of the scope, and then the TypeResolutionState object is used as a key to cache the found type.
A scope should not hold on to the default TypeResolutionState object, but should always refer to the parent's TypeResolutionState object when no PowerShell class defined in itself. When a PowerShell class is defined in a scope, a new TypeResolutionState will be created for the specific scope.

PR Context

PR Checklist

@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Dec 5, 2019
@TravisEz13

Copy link
Copy Markdown
Member

Rob Holt (@rjmholt) Can you review?

@iSazonov

Copy link
Copy Markdown
Collaborator

What is a design intention - runspaces is boundaries of visibility of c# types, ps classes, objects, modules?
If before the PR I define a ps class in interactive session and run a job (or foreach -parallel) then after the change the job will does not see the class?

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Dec 10, 2019 •

Copy link
Copy Markdown
Member Author

PowerShell class is visible only in the scope where it's defined and the child scopes of that scope. It's a scope thing, just like you define a function.

@daxian-dbw

Copy link
Copy Markdown
Member Author

Actually, Ilya (@iSazonov) brings up a good point and makes me believe this should be included in rc.1. If people started to depend on the wrong behavior, it will be much worse to break it in 7.1.0.

@ghost

Copy link
Copy Markdown

🎉v7.0.0-rc.1 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerShell classes leak to other runspaces on macOS

6 participants