#2038: System.Posix.Resource.setResourceLimit gives "setResourceLimit: invalid
argument (Invalid argument)"
--------------------------------------+-------------------------------------
    Reporter:  slyfox                 |       Owner:          
        Type:  bug                    |      Status:  new     
    Priority:  normal                 |   Component:  Compiler
     Version:  6.8.1                  |    Severity:  major   
    Keywords:  regression, ffi, unix  |    Testcase:          
Architecture:  x86                    |          Os:  Linux   
--------------------------------------+-------------------------------------
 GHC-6.6.1 worked correctly in setResourceLimit,
 GHC-6.8.2 gives me an error:
 {{{
 $ ./m
 m: setResourceLimit: invalid argument (Invalid argument)
 }}}
 A little exploration (strange rlim_max value). Seems to be a bug
 in haskell -> C type conversion.
 {{{
 $ strace -etrace=setrlimit ./m
 setrlimit(RLIMIT_CPU, {rlim_cur=3, rlim_max=0}) = -1 EINVAL (Invalid
 argument)
 m: setResourceLimit: invalid argument (Invalid argument)
 }}}
 Code source:
 {{{
 import System.Exit              (exitWith, ExitCode(ExitSuccess))
 import System.IO                (putStrLn)
 import System.Posix.Resource

 rlimit = ResourceLimit 3

 f = do
     putStrLn "whoooooo"
     f
 main = do
     setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit)
     r <- getResourceLimit ResourceCPUTime
     let (ResourceLimit s) = softLimit r
     let (ResourceLimit h) = hardLimit r
     putStrLn $ show s
     putStrLn $ show h
     f
     exitWith ExitSuccess
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2038>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to