GoogleChromeLabs / chromeos_smart_card_connector

Smart Card Connector App for Chrome OS
https://chrome.google.com/webstore/detail/smart-card-connector/khpfeaanjngmcnplbdlpegiifgpfgdco
Apache License 2.0
134 stars 49 forks source link

[libusb] Avoid recursion in the stress test #1121

Closed emaxx-google closed 8 months ago

emaxx-google commented 8 months ago

Change the ControlTransfersMultiThreadedStressTest's fakes to reply asynchronously from the main thread, instead of immediate synchronous replies.

This is better because it avoids reentrant recursive calls ("request1=>response1=>request2=>response2=>...") and excessive call stack usage from hundreds of nested calls. The latter is especially a problem in WebAssembly builds with debugging flags on.

In the real-world usages, this kind of reentrancy never happens because USB APIs are asynchronous.

The fix should unblock upreving to a more recent Emscripten version, as for some reason the stack usage grew in it and made the test very flaky without this fix.

github-actions[bot] commented 8 months ago

Continuous Integration: All tests passed. C/C++ test coverage: 73.29% lines.