[GHC] #8939: Should check the return value of clock_gettime

#8939: Should check the return value of clock_gettime -------------------------------------------+------------------------------- Reporter: uznx | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- In `ghc-7.6.3/rts/posix/GetTime.c`, function `StgWord64 getMonotonicNSec(void)`: The return value of `clock_gettime` should be checked, and if the value is not 0 (success), it should fall back to `gettimeofday`. The following patch demonstrates a possible fix: {{{ --- pre/rts/posix/GetTime.c 2013-04-18 17:22:47.000000000 -0400 +++ ghc-7.6.3/rts/posix/GetTime.c 2014-03-28 09:52:08.537125998 -0400 @@ -84,19 +82,22 @@ #ifdef HAVE_CLOCK_GETTIME struct timespec ts; + int res= clock_gettime(CLOCK_ID, &ts); + if(res==0) return (StgWord64)ts.tv_sec * 1000000000 + (StgWord64)ts.tv_nsec; #elif defined(darwin_HOST_OS) uint64_t time = mach_absolute_time(); return (time * timer_scaling_factor_numer) / timer_scaling_factor_denom; -#else +#endif + { //fallback struct timeval tv; gettimeofday(&tv, (struct timezone *) NULL); return (StgWord64)tv.tv_sec * 1000000000 + (StgWord64)tv.tv_usec * 1000; -#endif + } } Time getProcessElapsedTime(void) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8939 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8939: Should check the return value of clock_gettime -------------------------------+------------------------------------------- Reporter: uznx | Owner: simonmar Type: bug | Status: closed Priority: normal | Milestone: Component: Runtime | Version: 7.6.3 System | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by simonmar): * status: new => closed * resolution: => fixed Comment: Already fixed in HEAD: ee1343712bb7854ef5b7180b1e600ac61be4ca13 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8939#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8939: Should check the return value of clock_gettime -------------------------------+------------------------------------------- Reporter: uznx | Owner: simonmar Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Runtime | Version: 7.6.3 System | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by hvr): * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8939#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC