<div dir="ltr"><div>Hi all,</div><div><br></div><div>I just learned the function `checkUserInterrupt` and played with it in my package today. At first, everything was good. However, I sensed something wrong when I interrupted my function and relaunched it. In my case, the thread number of OpenMP decreased to 1 after an user interruption.<br></div><div><br></div><div>According to the documentation, the `checkUserInterrupt` will throw an exception to trigger the C++ destructors on the stack. However, if I use `Rcout` several times (verbose mode of my function), then it will not throw the exception but leave the function directly.<br></div><div><br></div><div>Here is a toy example to demonstrate: <a href="https://gist.github.com/wush978/36c4e5d8324dd14040eecb4b1dd1c631">https://gist.github.com/wush978/36c4e5d8324dd14040eecb4b1dd1c631</a> <br></div><div><br></div><div>It uses `Rcout` / `std::cout` as a progressbar and check the user interruption. If the exception is thrown correctly, then a catch clause will handle the exception and write something to the `std::cerr`.<br></div><div><br></div><div>If I turn off the verbose mode, then the `checkUserInterrupt` always throws the exception. <br></div><div><br></div><div>If I turn on the verbose mode and use `jsize` to select the number of dot on the screen, then the `checkUserInterrupt` will exit the function immediately if `jsize` is large.  For example, `checkUserInterrupt` throws exception if `jsize = 5` but does not throw if `jsize = 100`.<br></div><div><br></div><div>If I use `std::cout` instead of `Rcpp::Rcout`, then everything goes right again. So, there might be something wrong even if `R_TopLevelExec` is used.<br></div><div><br></div><div>Well, I guess this bug might be hard to debug, but we should let the others aware about this at least, right?</div><div><br></div><div>Best,</div><div>Wush<br></div></div>