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,384
    • Issues 4,384
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 372
    • Merge Requests 372
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10171

Closed
Open
Opened Mar 19, 2015 by redneb@redneb

runghc has problem when the argument list is too big

The way runghc works is by calling ghc with some extra arguments. These extra arguments cause the argv passed to ghc to be larger than the original one. This can cause the size of argv to exceed the maximum allowed. This might seem like a minor issue, but it can confuse several unix tools that rely on exact calculations on the size of argv, such as xargs or find with the -exec option.

To demonstrate the problem, consider the following the program (call it print_size.hs):

import System.Environment
import System.Posix

main = getArgs >>= mapM_ printSize
  where
    printSize file = do
        st <- getSymbolicLinkStatus file
        putStrLn $ show (fileSize st) ++ " " ++ file

The program interpreters its argv as a list of files and prints their sizes.

Now suppose that you want to run the program without compiling it (i.e. by interpreting it) on a specific set files, as returned by find. For example, consider something like that:

find / -exec runhaskell print_size.hs {} +

If you run this, you will get the following error (multiple times):

runghc: /usr/bin/ghc: rawSystem: runInteractiveProcess: exec: resource exhausted (Argument list too long)

The problem here is that the -exec option of find, when used with the + switch, works as follows: it starts collecting the list of found files and just before the list exceeds the maximum allowed size for argv it runs the specified program on that list (it works this way in order to minimize the number of times the program is ran). Of course this is problematic because runghc will then increase the size of argv and because of that the call to ghc might fail.

The same thing happens if you try to run the following as well:

find / -print0 | xargs -0 runhaskell print_size.hs
Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#10171