Artifacts Associated With Ticket 758110ffffffffff
Ticket change [f7b0109757] (rid 91416) by hgiese on 2003-06-20 19:07:49:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hello out there, the command dict info "" leads to a crash in my Borland generated Tcl 8.5a0 (on Win98). Here is what happens on my machine: - The first time around in DictInfoCmd the TclObj in question is not of type dictionary and so it gets converted via a call to SetDictFromAny. - Then the variable 'Dict *dict' is properly initialised. Inspecting it I see that its 'table' element has its element 'numEntries' set to '0' - reasonable. - But then within Tcl_HashStats one calculates average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; with tablePtr->numEntries being '0' -> BOOM. I would suggest the following change in function "Tcl_HashStats" (file tclHash.c): Put the line average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; into a conditional like /* * On machines not supporting "automatic NAN handling" or such, we * really should test for the denominator == 0 */ if ( tablePtr->numEntries ) average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; This will return a value of 0.0 for the average - which is maybe not exactly right but a reasonable value for an empty dictionary. Best regards Helmut Giese - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "hgiese"
- subsystem initialized to: "15. Dict Object"
- title initialized to: "patch for 'dict info {}'"
- type initialized to: "Patch"
Ticket change [8e8db3eafa] (rid 120129) by dkf on 2003-06-23 22:07:30:
- subsystem changed to: "10. Objects"
Ticket change [4771f1f173] (rid 99706) by dkf on 2003-06-23 22:07:31:
- priority changed to: "9 Immediate"
Ticket change [0f697b36bc] (rid 94785) by nobody on 2003-06-23 22:51:26:
- icomment:
Logged In: NO Hi Donal, meanwhile I got some more information. It seems possible to turn off floating point exceptions, thus (maybe) getting a NAN result like you do on Windows, too - haven't tested it yet. This leads me to the question: How does it run on Windows without the above patch? Returns a NAN? Throws an exception? It could be that VC++ leaves (floating point) exceptions disabled (appears to be the default) and Borland does not, so a better patch might be to have Borland behave like VC - which would mean a different patch and would eliminate the need for the one above. Maybe let it rest for a couple of days, 'til I got time to further look into this. Best regards Helmut Giese
- login: "nobody"
- mimetype: "text/plain"
- username: "nobody"
- icomment:
Ticket change [30c7640a67] (rid 93317) by dkf on 2003-06-25 02:59:05:
- closedate changed to: "2003-06-24T19:59:05"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 FP exceptions are a separate matter, but there's no real reason for that code to divide by zero in the first place.
- login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dkf"
Ticket change [d0ace9cd30] (rid 113221) by hgiese on 2003-06-25 03:58:30:
- icomment:
Logged In: YES user_id=522169 Hi Donal, I was almost ready to withdraw the patch: 1) I figured you were content of getting a NAN for 'avg'. 2) Meanwhile I'm a bit further ahead on the way to Borland & Tcl Nirvana - I don't GP at this test, so it's not a ral issue for me anymore. Of course, if you think that any division by zero should be avoided - well, put in the conditional. For me, I consider this (tiny) issue closed - got bigger problems with Borland :( Best regards Helmut Giese
- login: "hgiese"
- mimetype: "text/plain"
- username: "hgiese"
- icomment:
Ticket change [4f1c88ae43] (rid 125770) by dkf on 2003-06-25 15:18:55:
- icomment:
Logged In: YES user_id=79902 Bah. There was just no need to ever divide by zero anyway in that code. It had the feeling of a case never considered by the original author (and that code is one of the oldest parts of Tcl, dating from before the CVS archive. IIRC, it was exactly like that in 7.4b1 which was the first version of Tcl I've ever looked at...)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment: