Skip to content
Tcl Source Code View Ticket
Login

View Ticket

FD_SET macros must be used

Closed / Fixed3486554fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2012-02-10 14:55:28
This report is here to document a past fix, but is nonetheless important as a reference for people encountering the associated bugs in older versions, since these bugs have not been reported here.

Prior to Check-in [e496f9ef50] by Daniel A. Steffen,  2009-04-10 20:46:21,

* unix/tclUnixChan.c: TclUnixWaitForFile(): use FD_* macros * macosx/tclMacOSXNotify.c:to manipulate select masks (Cassoff). Bug 1960647

there were dangerously non-portable shift manipulations in TclUnixWaitForFile(). These have been properly replaced by the clean FD_SET et al. macros by Daniel.

Here is the behavior, observed independently by me on 8.4.13 and by evilotto on 8.4.12, both on x84_64 Linux:

A fileevent readable on a high descriptor (above 32) repeatedly fires, but the [read]s done on it don't consume any bytes, leading to a busyloop known as "select bomb". The failing bitshifts misdirected the setting of the select() bits.

Attached scripts, courtesy of evilotto, expose the behavior.
Also, the problem is likely to occur under load when using [package require httpd] asynchronously (many simultaneous requests must be active).
ferrieuxplain2012-02-10 21:56:18
File Added - 435415: selectbomb1.tcl
ferrieuxplain2012-02-10 21:56:45
File Added - 435417: selectbomb2.tcl
ferrieuxplain2012-02-10 21:57:29
File Added - 435419: selectbomb3.tcl
ferrieuxplain2012-02-10 21:58:12
Closing since it was fixed nearly 3 yrs ago.
ferrieuxplain2012-02-10 22:02:25
Reopening since it was never backported to 8.4.
Pending specific action, the 8.4 branch remains crippled in that regard: don't use 8.4 on x86_64 !!!
ferrieuxplain2012-03-05 01:49:19
In case a 8.4.20 is rolled out...
ferrieuxplain2012-03-05 01:53:17
Daniel, any objection against a backport of this specific cleanup to 8.4 ?
dasplain2012-03-05 09:21:07
none at all, please feel free!
das Ticket [3486554fff]: 1 change [History diff]2012-03-05 09:21:14
ferrieuxplain2012-03-06 00:30:24
Committed to tip of core-8-4-branch
Log in (anonymous is fine) to add a comment.

Attachments: