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

.NET library multithreading problems #186

Open
nd1012 opened this issue Nov 22, 2023 · 1 comment
Open

.NET library multithreading problems #186

nd1012 opened this issue Nov 22, 2023 · 1 comment

Comments

@nd1012
Copy link

nd1012 commented Nov 22, 2023

After reading #59 I was confident that I could do it - but multithreading doesn't work for me. I've created a MS Test project that can reproduce the problem: When using a Tpm2 from multiple threads, it won't work - see https://github.com/nd1012/Demo/tree/TSS-Multithreaded/TPM

Example 1: https://github.com/nd1012/Demo/blob/c802a62c36ed1086a82e6ed9a4054fa812bab5db/TPM/TPM%20Tests/Tpm2Tests.cs#L9
Only a few HMACs will be created (usually 5-6), then all other tasks fail.

Example 2: https://github.com/nd1012/Demo/blob/c802a62c36ed1086a82e6ed9a4054fa812bab5db/TPM/TPM%20Tests/SimulatorTests.cs#L9
I guess the test would run forever, 'cause there seems to be a dead-lock somewhere?

The tests use the simulator and a real TPM2 - both fail with multithreading.

Am I doing it wrong, or is there a bug?

@nd1012
Copy link
Author

nd1012 commented Nov 28, 2023

I had to find a solution for this problem fast, so I'm now using a singleton Tpm2 instance only, which I access synchronized from multiple threads - and this works like a charm. But, of course, it does decrease the apps performance in some places, where threads want to access the Tpm2.

I wonder how someone could use multiple Tpm2 instances in multiple thread without running into problems!? For me it doesn't work at all. Anyway, at the moment I'm fine with thread synchronized singleton Tpm2 instance access, and try to reduce TPM2 usage to a minimum only.

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

No branches or pull requests

1 participant