Re: select() clobbering the timeout

Richard B. Johnson (root@chaos.analogic.com)
Mon, 10 May 1999 15:28:37 -0400 (EDT)


On Mon, 10 May 1999, Roger Espel Llima wrote:

> I recently came across something strange on one Linux server: select()
> calls that time out suddenly started clobbering the timeout value with
> garbage.
>
> This is a UP P-II running kernel 2.0.35, with an uptime of 254 days.
> It's also a production server, and it's otherwise running fine. The
> weird behavior only started 5 days ago, and we only noticed it because
> it made zsh appear to hang.
>
> Now it's predictable: a test program shows that select() clobbers the
> timeout value everytime the timeout expires, but not when it returns
> early (because of input or a singal). I've single-stepped through the
> disassembly of select() in libc, and it appears clearly that the
> clobbering must happen in the kernel itself. I can't reproduce it on
> any other kernel, but then again, that 2.0.35 took 8 months to start
> doing it.
>
> I'm posting this not to ask for a fix, but just in case someone gets
> inspired to look at it, or can quickly say "that got fixed in 2.0.36" or
> whatever ...
[SNIPPED]

`man select` on my system explicitly states;

"On Linux, timeout is modified to reflect the amount of time
not slept; most other implementations do not do this."

Therefore, it should always be modified unless it returns instantly
because there is activity on the fd. The kernel may have changed the
order in which it checks the time and the fd so programs that rely
on older behavior may be broken.

Since systems can modify the structure (it's not const), code
should not rely on it remaining untouched.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/