Fixed deadlock in stubs (cherry picked from commit 68860ca)
(cherry picked from commit f2acb20)