Skip to content

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

Merged
thoemmi merged 6 commits intothoemmi:masterfrom
kborowinski:master
Jan 7, 2024
Merged

Workaround for NullReferenceException when extracting multiple 7zip archives simultaneously on PS 7.4.0#89
thoemmi merged 6 commits intothoemmi:masterfrom
kborowinski:master

Conversation

@kborowinski
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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