Tcl Source Code

Artifact [6c3522e59a]
Login

Artifact 6c3522e59af8a8eb0d7d2cb8b2c865ba408d71de:

Ticket change [6c3522e59a] - New ticket [3d3124d01d] tclStrToD can fail with -ftrapv compiler option. by anonymous 2014-03-06 15:27:31.
D 2014-03-06T15:27:31.927
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment If\stcl\sis\scompiled\swith\sthe\s"-ftrapv"\soption\s(which\sadds\schecks\sfor\sinteger\soverflow)\sthe\sstring\sto\sinteger\sconversion\scode\sin\stclStrToD.c\sfails\swhen\sparsing\sthe\smost\snegative\s64-bit\sinteger\s(-9223372036854775808).\r\n\r\nThis\smanifests\sitself\sin\sthe\sclock\scommand:\r\n\r\n%\sclock\sformat\s[clock\sseconds]\s-format\s"%d-%b-%Y"\r\nProcess\s4807\sstopped\r\n*\sthread\s#1:\stid\s=\s0x4e9b38,\s0x000000010009ebcc\slibtcl8.5.dylib`TclParseNumber(interp=0x0000000000000000,\sobjPtr=<unavailable>,\sexpected=0x00000001000ca82e,\sbytes=<unavailable>,\snumBytes=-1,\sendPtrPtr=0x0000000000000000,\sflags=<unavailable>)\s+\s5628\sat\stclStrToD.c:560,\squeue\s=\s'com.apple.main-thread,\sstop\sreason\s=\sEXC_BAD_INSTRUCTION\s(code=EXC_I386_INVOP,\ssubcode=0x0)\r\n\s\s\s\sframe\s#0:\s0x000000010009ebcc\slibtcl8.5.dylib`TclParseNumber(interp=0x0000000000000000,\sobjPtr=<unavailable>,\sexpected=0x00000001000ca82e,\sbytes=<unavailable>,\snumBytes=-1,\sendPtrPtr=0x0000000000000000,\sflags=<unavailable>)\s+\s5628\sat\stclStrToD.c:560\r\n\s\s\s557\s\t\t\s\s\s\s}\selse\sif\s(flags\s&\sTCL_PARSE_OCTAL_ONLY)\s{\r\n\s\s\s558\s\t\t\tgoto\szeroo;\r\n\s\s\s559\s\t\t\s\s\s\s}\selse\sif\s(isdigit(UCHAR(c)))\s{\r\n->\s560\s\t\t\tsignificandWide\s=\sc\s-\s'0';\r\n\s\s\s561\s\t\t\tnumSigDigs\s=\s1;\r\n\s\s\s562\s\t\t\tstate\s=\sDECIMAL;\r\n\s\s\s563\s\t\t\tbreak;\r\n\r\nbecause\sthe\sclock\scommand\sat\ssome\spoint\sgets\sto\shere\sin\sclock.tcl:\r\n\r\n\s\s\s3596\s\s\s\s\sset\sr\s{}\r\n\s\s\s3597\s\s\s\s\sset\slastTime\s$MINWIDE\r\n\s\s\s3598\s\s\s\s\sforeach\st\s$times\sc\s$codes\s{\r\n\s\s\s3599\s\s\s\s\s\s\s\s\sif\s{\s$t\s<\s$lastTime\s}\s{\r\n\s\s\s3600\s\s\s\s\s\s\s\s\s\s\s\s\sreturn\s-code\serror\s"$fileName\shas\stimes\sout\sof\sorder"\r\n\s\s\s3601\s\s\s\s\s\s\s\s\s}\r\n\s\s\s3602\s\s\s\s\s\s\s\s\sset\slastTime\s$t\r\n\r\nThe\scrash\shappens\sin\sline\s3599\swhen\s$t\sis\scompared\swith\s$MINWIDE.\sThis\scode\sdoesn't\slook\squite\sright\sto\sme\sas\s$t\scan\snever\sbe\sless\sthan\s$lastTime\sthe\sfirst\stime\sthrough\sas\s$lastTime\sis\sthe\smost\snegative\snumber.\sShouldn't\slastTime\sbe\sinitialized\swith\sthe\sfirst\stime\sin\sthe\slist?\sOr\sgiven\sthat\slastTime\sis\spresumably\sseconds\sthe\sarbitrary\schoice\sof\s$MINWIDE\sto\sseed\sit\scould\sbe\ssomewhat\sdifferent?\r\n\r\nI'm\snot\ssure\swhether\sthe\sbug\sis\sin\stclStrToD\s(because\sit\sdeliberately\soverflows\sand\s-ftrapv\sshould\snever\sbe\sused)\sbut\sthere\ssurely\sdoes\sseem\sto\sbe\sa\sbug\sin\sclock.tcl\sas\swell.\r\n\r\nFor\sreference\sthis\salso\sfails:\r\n\r\n%\sset\slast\s-9223372036854775808\r\n-9223372036854775808\r\n%\sincr\slast\r\nIllegal\sinstruction:\s4\r\n\r\nThis\sis\son\sOS\sX\sMavericks\swith\sclang\sbut\scolleagues\sreport\sa\ssimilar\sproblem\son\slinux\swith\sgcc.\r\n\r\nApologies\sif\sthis\sis\sa\sduplicate\sas\sI've\shad\strouble\sfinding\show\sto\ssearch\sthe\sticket\sdatabase.
J foundin 8.5.15
J is_private 0
J login anonymous
J priority 5\sMedium
J private_contact 7de6c5b3e942e3c0d4c64472ecfc87b370d5b7b8
J resolution None
J severity Important
J status Open
J submitter anonymous
J subsystem 11.\sConversions\sFrom\sString
J title tclStrToD\scan\sfail\swith\s-ftrapv\scompiler\soption
J type Bug
K 3d3124d01dabb46584e39877d44802bf5e8f4952
U anonymous
Z 459c63ea1d2b2c8801230ca013ce12f2