Skip to content

Conversation

@dantraMSFT
Copy link
Contributor

@dantraMSFT dantraMSFT commented Jan 9, 2018

Fixes #5733
Parameter binding has an assert that expects the argument value to be an array when the AST for the argument is an array. This assertion fails when the argument is encoded, such as when the -encodedarguments command-line parameter is used. The assert causes a process crash when running tests for debug builds.

The fix removes this assert since the method does not know the name of the argument being bound.

PR Checklist

Note: Please mark anything not applicable to this PR NA.

@dantraMSFT dantraMSFT requested review from TravisEz13, adityapatwardhan and daxian-dbw and removed request for BrucePay and daxian-dbw January 9, 2018 20:08
@dantraMSFT dantraMSFT changed the title Remove overly restrictive Diagnostics.Assert - cannot handle -encodedarguments NativeCommandParameterBinder.appendOneNativeArgument: Remove overly restrictive Diagnostics.Assert - cannot handle -encodedarguments Jan 9, 2018
@lzybkr
Copy link
Contributor

lzybkr commented Jan 9, 2018

I used to add too many assertions, but do so much less these days - so I feel like I added this for a good reason.

I think a better fix would be to not pass the ast for the minishell code path because the parameter values no longer match up with the ast properly anyway.

@dantraMSFT
Copy link
Contributor Author

@lzybkr: I'm sure there was a reason but, at the end of the day, test runs consistently fail against debug builds due to this assert and consistently pass in release builds. In short, this assert isn't providing any value since debug builds are only run privately.

if you do have a good reason for leaving it in, let me know. In lieu of one, I'm reluctant to make a functional change to address this.

@lzybkr
Copy link
Contributor

lzybkr commented Jan 10, 2018

The assertion caught a contract violation - the ast does not match the argument. Contract violations should not be "fixed" by ignoring the assertion.

If everything works today, code added in the future might not realize the contract is violated and do strange things.

You can make a change in this area with some confidence because it is well tested in our tests, there is plenty of time before the next release, and I will review the fix.

@dantraMSFT
Copy link
Contributor Author

Then perhaps it shouldn't be an assert. The contract is being violated multiple times a test run right now.

@lzybkr
Copy link
Contributor

lzybkr commented Jan 10, 2018

It's an internal api for code that changes infrequently - an assert is reasonable.

@dantraMSFT
Copy link
Contributor Author

@lzybkr: I have to say that I would be open to your argument if we had a process for running tests against debug builds but we don't and, in fact, this assert always failed in test runs.

That said, I'll update the PR with a proposed runtime fix.

…es an assert failiure.

Revert previous change - restore the Diagnostics.Assert statement.
@TravisEz13 TravisEz13 assigned TravisEz13 and unassigned daxian-dbw Jan 10, 2018
@dantraMSFT
Copy link
Contributor Author

@lzybkr: Do you have any additional feedback?

@lzybkr lzybkr merged commit d911bac into PowerShell:master Jan 12, 2018
@dantraMSFT dantraMSFT deleted the dantra/issue5733 branch January 12, 2018 21:08
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.

Debug assert "array argument and ArrayLiteralAst differ in number of elements" while running ConsoleHost tests

4 participants