Re: [Haskell-cafe] Debugging misbehaving multi-threaded programs
On Thu, Jun 11, 2009 at 12:40 AM, Ketil Maldeke...@malde.org wrote: Evan Klitzke e...@eklitzke.org writes: [...] Unfortunately, this doesn't seem to work; whenever the program terminates due to running out of heap space, the generated .prof file is empty. Unless there's some specific problem with profiling in combination with threading, you can get heap profiling from a crashing program. Not what you wanted, but you might at least be able to see what is allocated. After fiddling around a bit, I found out that you can get a heap profile from a program that dies from an error, but not one that dies from actually running out of heap space. I was able to take advantage of this by making the main thread do a threadDelay and then error, with the threadDelay timed to occur during the program's misbehavior. -- Evan Klitzke e...@eklitzke.org :wq ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Debugging misbehaving multi-threaded programs
I've written a multi-threaded Haskell program that I'm trying to debug. Basically what's happening is the program runs for a while, and then at some point one of the threads goes crazy and spins the CPU while allocating memory; this proceeds until the system runs out of available memory. I can't fix this without figuring out what code is being executed in the loop (or at least which thread is misbehaving, which would narrow things down a lot). I was hopeful that I could compile the program with profiling support and then use +RTS -M100M along with some of the RTS profiling options and get profiling information on CPU and memory usage at the time that my program runs out of memory. The thinking here is that nearly all of the CPU time and heap space will be from the misbehaving thread, so at that point I could do more investigation into exactly what is happening. Unfortunately, this doesn't seem to work; whenever the program terminates due to running out of heap space, the generated .prof file is empty. Another strategy I tried was running the program in ghci and use -fbreak-on-exception and :trace; by hitting Ctrl-C I was hopeful I'd stop the program in whatever is looping (this is all described and suggested in the ghc docs). Unfortunately, this also didn't seem to work, because the Ctrl-C only stops the main thread. Does anyone have any tips for dealing this? Have other people run into similar problems? I'm out of ideas, so I'm open to any suggestions. -- Evan Klitzke e...@eklitzke.org :wq ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Text formatting question
I'm writing code with hslogger, and I'm finding myself frequently writing things like this: infoM $ printf %s saw %s with %s (show x) (show y) (show z) On #haskell I asked about why you can't have use %s with any instance of (Show a), and augustss, the Text.Printf maintainer, pointed out that it's not possible in Haskell 98 because of overlapping instances. So I'm trying to figure out the best way to work around this in my code. Some of the logging statements can get kind of long, so the ability to elide the calls to `show` would be nice. So what's the best way to do this? I was thinking of making my own variant of printf that only accepted the %s formatter and took (Show a)'s as arguments, but there might be a simpler way? Another thing is the code is already fairly GHC specific at this point, so if there are GHC extensions that might be useful here that I don't know about, I'm interested in hearing about them. Thanks. -- Evan Klitzke e...@eklitzke.org :wq ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Cheat Sheet?
Has anybody made (or have a link to) a Haskell reference cheat sheet? I'm thinking of a nice LaTeXed PDF in the 1-10 page range (e.g. something like this http://www.tug.org/texshowcase/cheat.pdf) with the basics of the language syntax, the type declarations for the common type classes, the type signatures of the most commonly used functions in the Prelude and other common modules, and so forth? The Haskell standard library is very large for a newcomer (even just the Prelude!), and as a learner of the language I find myself spending a lot of time looking up Prelude functions and syntax details -- having all of this in a short PDF document that I could have offline would be very useful. -- Evan Klitzke [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe