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,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • 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
  • #17414

Closed
Open
Opened Oct 29, 2019 by Luite Stegeman@luiteDeveloper

File read/write operations >= 2GiB fail on macOS with an "Invalid argument" exception

Summary

File reads/writes bigger than 2GB result in an "Invalid argument" exception on macOS. Files bigger than 2GB still work, but individual read/write operations bigger than 2GB fail.

This was already reported for the bytestring library, but the actual problem is in base. I didn't see an earlier report.

bytestring report: https://github.com/haskell/bytestring/issues/153

Python has a workaround for this issue and more discussion: https://bugs.python.org/issue24658

Steps to reproduce

{-# LANGUAGE ScopedTypeVariables #-}
import Foreign.Ptr (Ptr)
import Foreign.Marshal.Alloc (mallocBytes, free)
import System.IO (hPutBuf, withBinaryFile, IOMode (WriteMode)) 

-- more than 2GiB
numBytes :: Int
numBytes = 2264375889

main :: IO ()
main = do
  (ptr :: Ptr ()) <- mallocBytes numBytes
  -- the next line produces the exception on macOS
  withBinaryFile "test.out" WriteMode (\h -> hPutBuf h ptr numBytes)
  free ptr

Expected behavior

The base library provides operating system independent buffering and encoding functionality. I think it should work around operating system peculiarities and write all the data to the test.out file without throwing an excepion.

Environment

Tested with GHC 8.6.5 on macOS 10.14.6

Assignee
Assign to
8.8.2
Milestone
8.8.2 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#17414