Open powercode opened 6 years ago
Looks like when ToString()
is called to get the VariableDetails.ValueString
of the property X
we're on a different thread. I'm surprised it actually creates the event though. I wouldn't have thought that thread would have Runspace.DefaultRunspace
set, in which case I'd expect a PSInvalidOperationException
instead.
I'm not sure there's a good way to distinguish a PSMethod
backed by a ScriptBlockMemberMethodWrapper
and a pure IL PSMethod
, so we may have to just make sure we're always on the pipeline thread while creating the VariableDetails
object.
Really interesting issue @powercode, thanks for the excellent report!
Steps to reproduce:
Put a breakpoint on the last line and try to view
$z
in the debugger.The thing that breaks is invoking a member method (static or instance) while evaluating ToString(). Accessing properties in ToString works fine, however.
It seems to be connected to events (
PSEngineEvent.OnScriptBlockInvoke
) being raised while an event is being processed. Not sure if this is a supported scenario. @BrucePay do you know the intention here?Possibly related is also this code in scriptblock.cs:
shouldGenerateEvent
is set to true ifSessionStateInternal.ExecutionContext != LocalPipeline.GetExecutionContextFromTLS()
.shouldGenerateEvent
is what causes the invocation ofPSEngineEvent.OnScriptBlockInvoke
that is hanging.Callstack