Bug in leap-second handling

Colin Plumb (colin@nyx.net)
Sat, 4 Apr 1998 23:52:33 -0700 (MST)


do_gettimeofday() does not take into account the TIME_INS or TIME_DEL state
bits when adding do_gettimeoffset() to the current xtime. This can result
in strang(er than usual) time warps around leap seconds.

For example, assuming that xtime starts out at 23:59:59.75 and HZ is 10,
and we read late in the the tick, so do_gettimeoffset always returns
0.9 seconds:

23:59:59.75 + 0.9 = 23:59:59.84 TIME_INS
23:59:59.85 + 0.9 = 23:59:59.94 TIME_INS
23:59:59.95 + 0.9 = 00:00:00.04 TIME_INS <<- BUG
23:59:59.05 + 0.9 = 23:59:59.14 TIME_OOB (This is really 23:59:60.)
23:59:59.15 + 0.9 = 23:59:59.24 TIME_OOB
23:59:59.25 + 0.9 = 23:59:59.34 TIME_OOB
23:59:59.35 + 0.9 = 23:59:59.44 TIME_OOB
23:59:59.45 + 0.9 = 23:59:59.54 TIME_OOB
23:59:59.55 + 0.9 = 23:59:59.64 TIME_OOB
23:59:59.65 + 0.9 = 23:59:59.74 TIME_OOB
23:59:59.75 + 0.9 = 23:59:59.84 TIME_OOB
23:59:59.85 + 0.9 = 23:59:59.94 TIME_OOB
23:59:59.95 + 0.9 = 00:00:00.04 TIME_OOB
00:00:00.05 + 0.9 = 00:00:00.14 TIME_WAIT

The one-second warp is misplaced. Is this the desired behaviour?

The corresponding bug can be seen with TIME_DEL:

23:59:58.75 + 0.9 = 23:59:58.84 TIME_DEL
23:59:58.85 + 0.9 = 23:59:58.94 TIME_DEL
23:59:58.95 + 0.9 = 23:59:59.04 TIME_DEL <<- BUG
00:00:00.05 + 0.9 = 00:00:00.14 TIME_WAIT

(This is kind of academic, since the earth is unlikely to speed up that much
unless there is a new ice age, but anyway...)

-- 
	-Colin

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu