GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — remoting: Handle DLLImport failure of libpsrpclient by dantraMSFT · Pull Request #5622 · PowerShell/PowerShell Conversation
Contributor
Issue #4029 exposed two problems when failing to load libpsrpclient.
This change addresses both of the above:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Dan Travison (dantraMSFT)
requested review from
Paul Higinbotham (PaulHigin) and
Mike Richmond (mirichmo)
as code owners
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave a comment
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field is different from array "_syncObjects" only by last letter - it is confusing.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
also related to issue #5566 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
LGTM, but I would like Paul Higinbotham (@PaulHigin) to have a look. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Andrew (@anmenaga) Do you want to sign off, or did you just comment? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Travis Plunk (@TravisEz13) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Travis Plunk (@TravisEz13) This should be ready to merge. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've been asked to wait for a review by Paul Higinbotham (@PaulHigin) or Dongbo Wang (@daxian-dbw) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Left two comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This assert should be removed because apparently _dataToBeSent can be null in that error path.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Never mind this comment. It's certainly right to assume _dataToBeSent != null when null != _dataSyncObjects 😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Will do.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid the sync object _syncObject by the following code:
if (null != _dataSyncObjects) { int promptResponseIndex = (int)DataPriorityType.PromptResponse; int defaultIndex = (int)DataPriorityType.Default; if (_dataToBeSent[promptResponseIndex] != null) { lock (_dataSyncObjects[promptResponseIndex]) { if (_dataToBeSent[promptResponseIndex] != null) { _dataToBeSent[promptResponseIndex].Dispose(); _dataToBeSent[promptResponseIndex] = null; } } } if (_dataToBeSent[defaultIndex] != null) { lock (_dataSyncObjects[defaultIndex]) { if (_dataToBeSent[defaultIndex] != null) { _dataToBeSent[defaultIndex].Dispose(); _dataToBeSent[defaultIndex] = null; } } } }
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You're right; I'll make the change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport and PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path. This change addresses both of the above but does not address the DllImport failure. * Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths. * Diagnosability: Log DllNotFoundException in WSManAPIDataCommon ctor and also include as the internal exception when throwing PSRemotingTransportException.
|
Dongbo Wang (@daxian-dbw) do you have any additional feedback? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Paul Higinbotham (@PaulHigin), Dongbo Wang (@daxian-dbw), please take a look at this; it's marked as GA. Thanks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
My comments have been addressed
| lock (_syncObjects[(int)DataPriorityType.Default]) | ||
| { | ||
| _dataToBeSent[(int)DataPriorityType.Default].Dispose(); | ||
| lock (_dataSyncObjects[promptResponseIndex]) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. I am not familiar with the error path but if _dataToBeSent array can contain null entries then it seems like so can _dataSyncObjects (_dataSyncObjects[promptResponseIndex] == null ?).
It seems like these arrays should be created in the PrioritySendDataCollection constructor...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Paul Higinbotham (@PaulHigin): _dataSyncObjects is populated when it is created. The entries are not null if the array is not null.
As far as when it is created, it appears the intent was to create both arrays at the same point. I saw no strong reason to change it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
But the _dataSyncObjects array is filled within a loop:
for (int i = 0; i < names.Length; i++)
{
_dataToBeSent[i] = new SerializedDataStream(_fragmentor.FragmentSize);
_dataSyncObjects[i] = new object();
}
If an exception is thrown within the loop then it is possible an array element is null. Is this not the error path we are worried about?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
SerializedDataStream's ctor does not currently throw.
Note that it should (it relies on Dbg.Assert) and I opened an issue for this: #5800
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Issue PowerShell#4029 exposed two problems when failing to load libpsrpclient. WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport; hindering diagnosability PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path. This change addresses both of the above: Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths. Diagnosability: Log the DllNotFoundException in WSManAPIDataCommon ctor and also include it as the internal exception when throwing PSRemotingTransportException.
Issue #4029 exposed two problems when failing to load libpsrpclient. WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport; hindering diagnosability PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path. This change addresses both of the above: Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths. Diagnosability: Log the DllNotFoundException in WSManAPIDataCommon ctor and also include it as the internal exception when throwing PSRemotingTransportException.
Issue PowerShell#4029 exposed two problems when failing to load libpsrpclient. WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport; hindering diagnosability PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path. This change addresses both of the above: Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths. Diagnosability: Log the DllNotFoundException in WSManAPIDataCommon ctor and also include it as the internal exception when throwing PSRemotingTransportException.
Issue PowerShell#4029 exposed two problems when failing to load libpsrpclient. WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport; hindering diagnosability PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path. This change addresses both of the above: Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths. Diagnosability: Log the DllNotFoundException in WSManAPIDataCommon ctor and also include it as the internal exception when throwing PSRemotingTransportException.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.