[GHC] #11041: EventLog write fails if entire buffer is not written

GHC ghc-devs at haskell.org
Sun Nov 1 09:29:01 UTC 2015


#11041: EventLog write fails if entire buffer is not written
-------------------------------------+-------------------------------------
        Reporter:  sseverance        |                Owner:
            Type:  bug               |               Status:  infoneeded
        Priority:  high              |            Milestone:  8.0.1
       Component:  Runtime System    |              Version:  7.10.2
      Resolution:                    |             Keywords:  eventlog
Operating System:  Unknown/Multiple  |         Architecture:  x86_64
 Type of failure:  Incorrect result  |  (amd64)
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * status:  new => infoneeded
 * failure:  None/Unknown => Incorrect result at runtime
 * priority:  normal => high
 * milestone:   => 8.0.1


Old description:

> Recently I was trying to use ThreadScope to run down a performance issue.
> I ran into what I believe is a corner case with flushing the eventlog
> data to disk. The program was generating hundreds of millions of events
> every few minutes.
>
> The function printAndClearEventBuf uses fwrite to flush the buffer to
> disk. What I observed is that with larger buffers it would only succeed
> in writing the first 4096 bytes. After it would print out its debugBelch
> message a number of times the program would crash. It does not crash if
> not run with the eventlog -l flag.
>
> My understanding is that fwrite might need to be called in a loop to
> ensure that all data is written. fwrite is not guaranteed to always write
> the entire requested buffer.
>
> I don't have a good test case for this, but if there is agreement about
> potential issues with flushing the buffer I am more than happy to provide
> a patch.

New description:

 Recently I was trying to use ThreadScope to run down a performance issue.
 I ran into what I believe is a corner case with flushing the eventlog data
 to disk. The program was generating hundreds of millions of events every
 few minutes.

 The function `printAndClearEventBuf` uses `fwrite` to flush the buffer to
 disk. What I observed is that with larger buffers it would only succeed in
 writing the first 4096 bytes. After it would print out its `debugBelch`
 message a number of times the program would crash. It does not crash if
 not run with the eventlog `-l` flag.

 My understanding is that `fwrite` might need to be called in a loop to
 ensure that all data is written. `fwrite` is not guaranteed to always
 write the entire requested buffer.

 I don't have a good test case for this, but if there is agreement about
 potential issues with flushing the buffer I am more than happy to provide
 a patch.

--

Comment:

 For the sake of completeness of the ticket, what operating system did you
 observe this on?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11041#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list