[darcs-devel] [issue1524] Date conversion breaks down on NetBSD

Reinier Lamers bugs at darcs.net
Sat Aug 15 21:41:05 UTC 2009


New submission from Reinier Lamers <tux_rocker at reinier.de>:

Zooko gets an error when he does a 'darcs changes --xml-output' on NetBSD. The
message is:'darcs failed:  Time.toClockTime: invalid input'. It's in a buildbot
log that can be found on http://allmydata.org/buildbot/builders/MM netbsd4 i386
warp/builds/70/steps/build/logs/stdio .

It appears that this bug is triggered via the Darcs.Patch.Info.to_xml and
Darcs.Patch.Info.friendly_d functions in darcs. toClockTime is then called on a
data structure that is produced by readPatchDate. 

toClockTime has the following ominous bit of source code:

     -- FIXME: check, whether this works on other arch's than Linux, too...
     -- 
     -- so we set it to (-1) (means `unknown') and let `mktime' determine
     -- the real value...
    let isDst = -1 :: CInt in   -- if _isdst then (1::Int) else 0

    if psec < 0 || psec > 999999999999 then
        error "Time.toClockTime: picoseconds out of range"
    else if tz < -43200 || tz > 43200 then
        error "Time.toClockTime: timezone offset out of range"
    else
      unsafePerformIO $ do
      allocaBytes (44) $ \ p_tm -> do
{-# LINE 548 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_tm	(fromIntegral sec  :: CInt)
{-# LINE 549 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p_tm	(fromIntegral minute :: CInt)
{-# LINE 550 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p_tm	(fromIntegral hour :: CInt)
{-# LINE 551 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 12)) p_tm	(fromIntegral mday :: CInt)
{-# LINE 552 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p_tm	(fromIntegral (fromEnum mon)
:: CInt)
{-# LINE 553 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 20)) p_tm	(fromIntegral year - 1900 ::
CInt)
{-# LINE 554 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p_tm	isDst
{-# LINE 555 "System/Time.hsc" #-}
	t <- throwIf (== -1) (\_ -> "Time.toClockTime: invalid input")
		(mktime p_tm)


Hence, I expect this problem will go away when we stop using toClockTime in
friendly_d.

----------
messages: 8169
nosy: dmitry.kurochkin, kowey, simon, thorkilnaur, tux_rocker
priority: urgent
status: unread
title: Date conversion breaks down on NetBSD

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1524>
__________________________________


More information about the darcs-devel mailing list