Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,333
    • Issues 4,333
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 370
    • Merge Requests 370
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #4427

Closed
Open
Opened Oct 22, 2010 by rl@cse.unsw.edu.au@trac-rl

hGetBuf sometimes reads fewer bytes than required

The attached program repeatedly calls hGetBuf and prints how much it wanted to read and how many bytes hGetBuf returned. It should be run on a sufficiently large file. On Cygwin, the last 4 lines of the output are:

4 4
608 523
4 4
300 300

Note that we requested 608 bytes but hGetBuf only returned 523 even though we weren't at the end of file (since subsequent reads succeeded).

I suspect the bug is in GHC.IO.Handle.Text.bufReadEmpty, namely here:

  loop :: FD -> Int -> Int -> IO Int
  loop fd off bytes | bytes <= 0 = return off

It should probably return so_far + off.

Trac metadata
Trac field Value
Version 7.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
7.0.1
Milestone
7.0.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#4427