Artifacts Associated With Ticket 957dbe231ccd7f31
Ticket change [476bce161d] (rid 146884) by fvanderhave on 2016-06-03 09:32:58:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
In tcl 8.6 there seems to be a bug of missing parentheses in the thread package. At the top of the file tcl8.6.1/pkgs/thread2.7.0/generic/threadCmd.c there is a definition #define THREAD_SEND_WAIT 1<<1 #define THREAD_SEND_HEAD 1<<2 It seems to me that this is intended to define which specific one bit to use in bitwise operations. These are used for example in ThreadSendObjCmd() in a line like: if (OPT_CMP(arg, "-async")) { flags &= ~THREAD_SEND_WAIT; } The problem is that the operator precedence of the bitwise not ("~") is higher than the the precedence of the shift left ("<<"). While the intended result seems to be to compute flags &= ~(1<<1); what is actually computed is flags &= (~1)<<1; As long as this operation is only done on the least significant used bit out of all bits in the bit mask, this "bug" probably has no practical effect, except invoking undefined behavior of shifting into and past the sign bit of a signed value. However, if it is indeed a bug, it has the potential to become a hard-to-notice more serious problem with later code changes. Please verify whether the intention is indeed to clear out one single bit, or that it clears also all bits that are less significant at the same time. In case the intention is to use 1<<1 and 1<<2 to specify a single bit in a bit-mask, my recommendation would be to include parentheses: #define THREAD_SEND_WAIT (1<<1) #define THREAD_SEND_HEAD (1<<2) The same problem and suggested fix applies to these three lines in the newer version in tcl8.6.5/pkgs/thread2.7.3/generic/threadCmd.c: #define THREAD_SEND_WAIT 1<<1 #define THREAD_SEND_HEAD 1<<2 #define THREAD_SEND_CLBK 1<<3 Best regards, Frans van der Have, developer at Scientific Volume Imaging. - foundin initialized to: "8.6"
- is_private initialized to: "0"
- login: "fvanderhave"
- priority initialized to: "5 Medium"
- private_contact initialized to: "77b78217bda604844f1ebd4c005e3cb7fbc8be50"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "fvanderhave"
- subsystem initialized to: "80. Thread Package"
- title initialized to: "Missing parentheses in #define LABEL 1<<1"
- type initialized to: "Bug"
Ticket change [9c1195a3c5] (rid 146888) by gahr on 2016-06-03 13:21:57:
- closedate changed to: "2457543.05691707"
- closer changed to: "gahr"
- icomment:
Fixed in [http://core.tcl.tk/thread/info/b52389dd2464bdb1]. Thanks!
- login: "gahr"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "gahr"