Closed thomasjm closed 5 years ago
Can this also be reproduced without requiring the use of non-standard tooling such as stack install
? Unfortunately my time budget is too limited to be able to deal with 3rd party build tools so I'd ask you to please provide repro instructions in accordance with the contribution guidelines which for this very reason state
Reproduction-instructions shall be expressed in terms of Haskell.org's standard tooling (i.e. cabal).
Ah sorry, missed that guideline. Actually I think this issue can be closed -- I posted about this on Reddit and someone simplified the repro to remove hslogger
: https://www.reddit.com/r/haskell/comments/d4h7ty/why_does_this_code_livelock_all_my_cpus_at_100/. Seems it's related to the FFI/forking in the other library.
Closing now, sorry for the noise...
I'm experiencing a really weird problem where a small Haskell program using
hslogger
will livelock and use all of the (8) CPUs on my laptop at 100%. I'm not totally sure thathslogger
is to blame but it definitely seems to be part of the interaction that is happening, and I'd greatly appreciate any help.The full repro can be found here: https://github.com/thomasjm/haskell-livelock-repro. You can simply clone this repo and run
stack install && high-cpu-debug-exe
.Here's the code and the debugging I've attempted:
This program sets up a simple log handler that prints to
stderr
. Then it runs a loop where it forks threads that do eitherspawnWithPty
(to create a new process inside a pseuo-terminal) orreadCreateProcess
(to create a normal process). I know this is weird, but if you remove either of these then it doesn't trigger the problem.+RTS -p h
but the profiling report doesn't show anything about the massive amount of CPU time being wasted (!)perf
to record the top symbols. 90% of the time is being spent ingcWorkerThread
but I'm not sure what to make of that fact.-debug
and running with+RTS -v
to see the runtime logging, but I haven't gotten any insight from that.spawnWithPty
does FFI to create new pseudo-terminals, and my current theory is that some kind of multithreading/FFI race condition is happening.