
Erik Hesselink wrote:
Hi Ryan,
I'm not quite sure of your use case, but lambdabot/mueval do something like this I think. From a brief look at the source [1] it seems they compute in a separate thread, then in another thread, wait until the timeout then kill the computation thread. Would something like that work for you?
That is not the whole story; the above mechanism is subject to the same problems as the original poster's program. mueval actually comes with a wrapper program ("mueval", source: "watchdog.hs") that invokes the actual interpreter ("mueval-core", source: "main.hs") as a subprocess; both programs implement a timeout, but the wrapper kills the interpreter if the internal timeout fails. This machinery predates -fno-omit-yields. But it's still useful because it also protects against blocking unsafe foreign calls and other scenarios where the RTS can become completely unresponsive, as well as potential holes in -fno-omit-yields. Cheers, Bertram