Fix stack overflow in folly::window
Summary: If the default inline executor is used for folly::window, and all the futures generated by the callback are also inline, then all spawn function calls (and their associated Futures) are added to the call stack and can overflow. This fixes that issue by using QueuedImmediateExecutor, which will put the executor callback into a thread-local queue, allowing the current function to exit and destruct all objects in its stack frame. Then, only the first call to QueuedImmediateExecutor in a thread is responsible for running each subsequent callback and will do so sequentially. This will end up allocating dynamic queues that reach a max size of two. It is possible to avoid a dynamic queue by writing a new Executor that only stores a single function, if that is too much of a performance cost. Reviewed By: yfeldblum Differential Revision: D7597731 fbshipit-source-id: cd8899e6c086ecff812050f7241e80f39c546706
Showing
Please register or sign in to comment