<div dir="ltr">what OS are you on?<div>what build options did you use?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 11, 2014 at 2:11 AM, Michael Jones <span dir="ltr"><<a href="mailto:mike@proclivis.com" target="_blank">mike@proclivis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am trying to debug a lockup problem (and need help with debugging technique), where hang means a thread stops at a known place during evaluation, and other threads continue.<br>
<br>
The code near the problem is like:<br>
<br>
       ec <- return $ encode command<br>
       l <- return $ BSL.length ec<br>
       ss <- return $ BSC.unpack ec<br>
<br>
It does not matter if I use let or return, or if the length is taken after unpack. I used return so I could use this code for tracing, with strictness to try to find the exact statement that is the problem:<br>
<br>
       traceEventIO "sendCommand"<br>
       ec <- return $ encode command<br>
       traceEventIO $ "sendCommand: encoded"<br>
       l <- ec `seq` return $ BSL.length ec<br>
       traceEventIO $ "sendCommand: size " ++ (show l)<br>
       ss <- ec `seq` return $ BSC.unpack ec<br>
<br>
When this runs, the program executes this many times, but always hangs under a certain condition.<br>
<br>
For good evaluations:<br>
<br>
7f04173ff700: cap 0: sendCommand<br>
7f04173ff700: cap 0: sendCommand: encoded<br>
7f04173ff700: cap 0: sendCommand: size 4<br>
7f04173ff700: cap 0: sendCommand: unpacked<br>
7f04173ff700: cap 0: Sending command of size 4<br>
7f04173ff700: cap 0: Sending command of size "\NUL\EOT"<br>
7f04173ff700: cap 0: sendCommand: sent<br>
7f04173ff700: cap 0: sendCommand: flushed<br>
<br>
for bad evaluation:<br>
<br>
7f04173ff700: cap 0: sendCommand<br>
7f04173ff700: cap 0: sendCommand: encoded<br>
<br>
The lockup occurs when length is taken.<br>
<br>
The difference between the working and non-working case is as follows:<br>
<br>
A wxHaskell callback stuffs some data in a TChan. A thread started at application startup is reading the TChan and calling the code that hangs. If it did not hang, it would send it by TCP to another process/computer.<br>
<br>
In the working case the callback pops a dialog, and passes data from one TChan to another TChan.<br>
<br>
In the failing case, the data is used to generate strings in a wxHaskell grid, then it is parsed, and a new data is made. The new data is a combination of old and new pieces of sub data. The shape of the date is identical, because I am not making any edits to the rows.<br>
<br>
So when data that the callback sends to TChan is unmodified, no hang. But when the data is used to make text, put it in the gui, process it, and generate new data, it hangs.<br>
<br>
As a test I modified the code so that the text is not put into the gui. The results are the same. This indicates it has something to do with creating strings and then data from strings and mixing old and new subdata. Strings are created with show. Data is created by pattern matching and generating numbers from strings. I should also point out that in the working case, the size of the resulting string is small, say 3. In the hang case, the resulting string would be long, say 5000-10000.<br>
<br>
I assume there are no limits to the size of ByteStrings or fundemental issues with the RTS stack/heap that require special settings.<br>
<br>
I am using the following revisions:<br>
<br>
GHC 7.8.3<br>
    base ==4.7.*,<br>
    mtl ==2.2.1,<br>
    containers == 0.5.5.1,<br>
    transformers ==0.4.1.0,<br>
    random == 1.0.1.1,<br>
    wx == 0.91.0.0,<br>
    wxcore == 0.91.0.0,<br>
    wxdirect == 0.91.0.0,<br>
    colour == 2.3.3,<br>
    stm == 2.4.2,<br>
    monad-loops == 0.4.2.1,<br>
    time == 1.4.2,<br>
    old-locale == 1.0.0.6,<br>
    fast-logger == 2.2.3,<br>
    network == 2.6.0.2,<br>
    bytestring == 0.10.4.0,<br>
    control-monad-loop == 0.1,<br>
    binary == 0.7.2.2,<br>
<br>
I know that nobody can have an answer based on this. But what I am hoping is either there is some known bug, or someone can guide me in narrowing it down. The event log does not have anything unusual in it. Other threads keep running, and I can exit the application normally. The thread does not throw an exception. It just hangs.<br>
<br>
When I run the app, I just use +RTS -v<br>
<br>
Perhaps there are some other options that might give more info?<br>
<br>
— SNIPPET of log —<br>
<br>
7fe544cfea40: cap 0: running thread 5 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: thread 5 stopped (yielding)<br>
7fe544cfea40: cap 0: running thread 5 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: thread 5 stopped (suspended while making a foreign call)<br>
7fe544cfea40: cap 0: running thread 5 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: thread 5 stopped (blocked on an MVar)<br>
7fe537eff700: cap 0: running thread 2 (ThreadRunGHC)<br>
7fe537eff700: cap 0: waking up thread 5 on cap 0<br>
7fe537eff700: cap 0: thread 2 stopped (yielding)<br>
7fe544cfea40: cap 0: running thread 5 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: sendCommand<br>
7fe544cfea40: cap 0: sendCommand: encoded<br>
7fe544cfea40: cap 0: sendCommand: size 3                               WORKS HERE<br>
7fe544cfea40: cap 0: sendCommand: unpacked<br>
7fe544cfea40: cap 0: Sending command of size 3<br>
7fe544cfea40: cap 0: Sending command of size "\NUL\ETX"<br>
7fe544cfea40: cap 0: sendCommand: sent<br>
7fe544cfea40: cap 0: sendCommand: flushed<br>
7fe544cfea40: cap 0: thread 5 stopped (blocked on an MVar)<br>
7fe537eff700: cap 0: running thread 2 (ThreadRunGHC)<br>
7fe537eff700: cap 0: thread 2 stopped (yielding)<br>
7fe537eff700: cap 0: running thread 2 (ThreadRunGHC)<br>
7fe537eff700: cap 0: thread 2 stopped (suspended while making a foreign call)<br>
7fe537eff700: cap 0: running thread 2 (ThreadRunGHC)<br>
7fe537eff700: cap 0: waking up thread 5 on cap 0<br>
<br>
…<br>
<br>
7fe537eff700: cap 0: fetchTelemetryServer: got lock<br>
7fe537eff700: cap 0: thread 45 stopped (yielding)<br>
7fe537eff700: cap 0: running thread 7 (ThreadRunGHC)<br>
7fe537eff700: cap 0: thread 7 stopped (heap overflow)<br>
7fe537eff700: cap 0: requesting parallel GC<br>
7fe537eff700: cap 0: starting GC<br>
7fe537eff700: cap 0: GC working<br>
7fe537eff700: cap 0: GC idle<br>
7fe537eff700: cap 0: GC done<br>
7fe537eff700: cap 0: GC idle<br>
7fe537eff700: cap 0: GC done<br>
7fe537eff700: cap 0: all caps stopped for GC<br>
7fe537eff700: cap 0: finished GC<br>
7fe537eff700: cap 0: running thread 7 (ThreadRunGHC)<br>
7fe537eff700: cap 0: sendCommand<br>
7fe537eff700: cap 0: sendCommand: encoded                       PROBLEM HERE<br>
7fe537eff700: cap 0: thread 7 stopped (heap overflow)<br>
7fe537eff700: cap 0: requesting parallel GC<br>
7fe537eff700: cap 0: starting GC<br>
7fe537eff700: cap 0: GC working<br>
7fe537eff700: cap 0: GC idle<br>
7fe537eff700: cap 0: GC done<br>
7fe537eff700: cap 0: GC idle<br>
7fe537eff700: cap 0: GC done<br>
7fe537eff700: cap 0: all caps stopped for GC<br>
7fe537eff700: cap 0: finished GC<br>
7fe537eff700: cap 0: running thread 7 (ThreadRunGHC)<br>
7fe537eff700: cap 0: thread 7 stopped (yielding)<br>
7fe537eff700: cap 0: running thread 2 (ThreadRunGHC)<br>
7fe537eff700: cap 0: thread 2 stopped (yielding)<br>
7fe544cfea40: cap 0: running thread 442 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: thread 442 stopped (suspended while making a foreign call)<br>
7fe544cfea40: cap 0: running thread 442 (ThreadRunGHC)<br>
7fe544cfea40: cap 0: thread 442 stopped (suspended while making a foreign call)<br>
7fe537eff700: cap 0: running thread 45 (ThreadRunGHC)<br>
7fe537eff700: cap 0: fetchTelemetryServer: unlock<br>
7fe537eff700: cap 0: fetchTelemetryServer<br>
7fe537eff700: cap 0: fetchTelemetryServer: got lock<br>
7fe537eff700: cap 0: fetchTelemetryServer: pump seq<br>
<br>
<br>
<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div><br></div>