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

Workaround for NullReferenceException when extracting multiple 7zip archives simultaneously on PS 7.4.0 #89

Merged
merged 6 commits into from
Jan 7, 2024

Conversation

kborowinski
Copy link
Contributor

@kborowinski kborowinski commented Jan 5, 2024

@thoemmi This is workaround for issue #88. I'll report this issue on PowerShell repository but in the meantime I have implemented this fix to make 7Zip4PowerShell behave reliably on PS 7.4.0. I have also made small Filter code refactoring for simplification. And I have also enclosed all progress pane paths in double quotes. When you have a time, please make this a beta release for testing (I did test it myself but better be safe than sorry)

@thoemmi thoemmi merged commit c19e42f into thoemmi:master Jan 7, 2024
@thoemmi
Copy link
Owner

thoemmi commented Jan 7, 2024

Thanks for the workaround @kborowinski . The actual issue is caused by the fact that for every progress change a new ProgressRecord instance is created?

I have published 2.4.1-beta0008 including your fix.

@kborowinski
Copy link
Contributor Author

@thoemmi During the test I've found that higher the number of ProgressRecord instances, the more often NRE is happening. So that's why I've refactored the code to reuse the ProgressRecord. It substantially limited the number of NREs, however they are still happening sometimes, and hence temporary workaround that swallows the NRE in try {} catch (NullReferenceException) {} block.

What keeps me wondering is that NREs are not happening on PS 5.1 at all. Also the NREs are occurring mostly on ProgressPane completion, i.e. Microsoft.PowerShell.ProgressPane.Hide(). It almost looks like occasionally the completion is happening twice.

I do believe that this is a race-condition in PowerShell as similar issue is open already (PowerShell/PowerShell#17497). There was a PR for it, implementing extra locks, but it's closed now (PowerShell/PowerShell#17498).

@thoemmi
Copy link
Owner

thoemmi commented Jan 8, 2024

I remember 12 years ago when I started 7Zip4Powershell, the main challenge was that 7zip raised the Compressing event in multiple threads, which Powershell didn't like. Therefore the peculiar ThreadedCmdlet implementation 🤷‍♂️

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.

2 participants