A sys_poll() ABI tweak
Most of the time, things just work. The int and long types tend to be the same on most architectures, and, in cases where they are different, glibc sign-extends the timeout value appropriately. Things go wrong, though, when a 32-bit process is running on an x86-64 system. In that case, the 32-bit sys_poll() function just passes the timeout value directly to the native kernel version, without sign extension. So if the timeout value is negative (an indication that poll() should wait forever if need be), the kernel will eventually see a large, positive timeout instead.
There are various ways this problem could be fixed. What Linus has chosen to do, though, is to just change the type of the timeout parameter to int inside the kernel. Since the timeout is now a 32-bit quantity on all systems, that particular source of confusion is removed. There is a small risk to this approach, though: it is possible that some program somewhere was actually making use of 64-bit timeouts. Doing so would require replacing or bypassing glibc (because its sign extension makes 64-bit timeouts unusable), so it's unlikely that anybody has bothered, but one never knows. If this change were to break a real application, it would have to be reverted in favor of a more complicated solution.
Linus's patch was merged for
3.3-rc5, so anybody who objects has a few weeks to make their concerns known.
Index entries for this article | |
---|---|
Kernel | Development model/User-space ABI |
Posted Feb 26, 2012 2:34 UTC (Sun)
by jzbiciak (guest, #5246)
[Link]
Posted Feb 27, 2012 19:47 UTC (Mon)
by dmarti (subscriber, #11625)
[Link]
Posted Mar 5, 2012 23:45 UTC (Mon)
by landley (guest, #6789)
[Link] (2 responses)
http://www.unix.org/whitepapers/64bit.html
Here's the rationale:
http://www.unix.org/version2/whatsnew/lp64_wp.html
And here's the insane legacy reasons Windows decided to do something else instead:
http://blogs.msdn.com/b/oldnewthing/archive/2005/01/31/36...
Rob
Posted Mar 6, 2012 7:03 UTC (Tue)
by khim (subscriber, #9252)
[Link] (1 responses)
Of course they are! Not always and anyway: number of 32 bit architectures dwarfs the number of 64 bit architectures, so what's your point?
Posted Mar 7, 2012 10:39 UTC (Wed)
by sdalley (subscriber, #18550)
[Link]
After reading landley's GP, and the references he supplied, I understand the subtleties of the actual situation.
After reading khim's post, I am left completely uninformed, and with the strong impression that the poster is an arrogant twerp. It's only an impression, though, and I could be wrong ...
A sys_poll() ABI tweak
Anyone who's actually using timeouts that long has probably already been tarred and feathered by their QA dept. How would you test them?
A sys_poll() ABI tweak
A sys_poll() ABI tweak
A sys_poll() ABI tweak
No, int and long _aren't_ the same size on "most" architectures.
They're the same size on 32 bit architectures, different on 64 bit.
A sys_poll() ABI tweak