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

TarInputStream does not run synchronously when used non-async #788

Closed
piksel opened this issue Oct 20, 2022 · 4 comments · Fixed by #791
Closed

TarInputStream does not run synchronously when used non-async #788

piksel opened this issue Oct 20, 2022 · 4 comments · Fixed by #791
Labels
async bug tar Related to TAR file format

Comments

@piksel
Copy link
Member

piksel commented Oct 20, 2022

This is a follow up from #786.

TarInputStream.GetNextEntry() seems to use the thread pool to run "asynchronously", even though it should be fully sync.
The async implementation takes an isAsync argument that should make it run totally synchronous when passed with false.

As of #787, deadlocks are avoided using .ConfigureAwait(false), but there is still a bug somewhere that caused this to happen in the first place.

@piksel piksel added bug tar Related to TAR file format async labels Oct 20, 2022
@flensrocker
Copy link
Contributor

https://sharplab.io/ is a good place to see the generated Async-StateMachine. It's just a bit of work to get all the relevant classes into one file to get an overview.

@flensrocker
Copy link
Contributor

I copied all relevant classes used by TarInputStream into one file and added the output from sharplab.io.

If someone wants to take a look... I don't know, when I have the time for it.

TarInputStream-SharpLabIo.zip

@piksel
Copy link
Member Author

piksel commented Oct 20, 2022

Just for reference, this is how a "async with isAsync" method should work:
https://sharplab.io/#v2:CYLg1APgAgDABFAjAVgNwFgBQWoGYEBMcAwnAN5ZxUL5QAcCAbADwCWAdgC4B8cAsgAoARgHsRAGzisAzgEFpAT3YBjAJTlK1LawBmcATPlK1GzFvPUoATiYA6ACIBTcQEMFAxDBiqMZi3ABfTQsoAHY4NGDArACgA==

As you can see in the output, the goto just skips the entire state-machine logic and, most importantly, does not call AwaitUnsafeOnCompleted.

@flensrocker
Copy link
Contributor

Found it by stepping through my sample app until the current thread-id switched.

There were two places where a false should be used for the isAsync argument. 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async bug tar Related to TAR file format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants