mask asynchronous exceptions to prevent memory leaks

these functions allocate resources and make them subject to
garbage collection later. if asynchronous exception arrives
in between, memory will be leaked.