Artifacts Associated With Ticket 862924ffffffffffffffffffffffffffffffffff
Ticket change [8442a491d5] (rid 117522) by tclfuchs on 2003-12-19 13:15:52:
- assignee initialized to: "hobbs"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I found some Memory leaks. Memory is allocated by c-system-functions like localtime() and assigned to variables, which are not freed afterwards. Might be, there are many more leaks of this kind (?!)... file tclGetDate.y, function NamedDay: Variable tm file tclGetDate.y, function NamedMonth: Variable tm file tclGetDate.y, function RelativeMonth: variable tm file tclGetDate.y, function TclGetDate: variable tm file tclUnixTime.c, function TclpGetTimeZone, variable timeDataPtr and variable stm
- foundin initialized to: "obsolete: 8.4.5"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "tclfuchs"
- subsystem initialized to: "41. Memory Allocation"
- title initialized to: "Memory Leak in Time/Date-Functions"
- type initialized to: "Bug"
Ticket change [9599a0ae18] (rid 106181) by dkf on 2003-12-19 21:34:59:
- assignee changed to: "kennykb"
- subsystem changed to: "06. Time Measurement"
Ticket change [9f500f99a0] (rid 96621) by tclfuchs on 2003-12-22 17:17:43:
- icomment:
Logged In: YES user_id=934391 Could you please also have a look at unix/tclUnixTime.c. Maybe it could be rewritten as struct tm *TclpGetDate(time, useGMT) TclpTime_t time; int useGMT; struct tm *temp; { CONST time_t *tp = (CONST time_t *)time; if (useGMT) { temp=gmtime(tp); free(tp); return temp; } else { temp=localtime(tp); free(tp); return temp; } } The same applies to /win/tclWinTime.c with variable tp, but this function is a bit more tricky. In /mac/tclMacTime.c the function TclpGetDate seems to be not-threadsafe. A pointer to static variable "statictime" is returned from this function, but this variable is influenced by other threads. Even in single-threaded programms problems arise, if not carefully used: The user has to copy the data of the returned pointer to another memory location, because the next call to TclpGetDate would override the result of the previous call. - login: "tclfuchs"
- mimetype: "text/plain"
- username: "tclfuchs"
- icomment:
Ticket change [4a8ae18679] (rid 126551) by kennykb on 2004-03-05 23:30:21:
- assignee changed to: "das"
- icomment:
Logged In: YES user_id=99768 The variable returned by 'localtime' is in fact supposed to be static, rather than dynamically allocated. If a memory management tool is reporting the 'struct tm' in these functions as being leaked, it is either the tool or the C library that is in error. Freeing the memory returned by 'localtime' would be a catastrophic bug. The code in tclUnixTime.c has been replaced with the 'ThreadSafeGMTime' and 'ThreadSafeLocalTime' functions some time ago. Those functions use gmtime_r and localtime_r if available, and protect the operation with a mutex if they are not available. The Unix code for these functions uses a thread-specific data block; these blocks are cleaned up automatically in Tcl_FinalizeThread upon exit from the thread. Since Classic Mac is not supported, and the proposal is afloat to move the mac/ directory to the Attic, I question whether it's necessary at the moment to do anything with tclMacTime.c. I'm assigning this bug over to the last known maintainer of the Mac code to see if he wants to do anything with it. In short: I see no leaks; the Classic Mac code may have issues with thread safety.
- login: "kennykb"
- mimetype: "text/plain"
- priority changed to: "1 Zero"
- username: "kennykb"
Ticket change [a53f213434] (rid 110339) by das on 2004-03-08 10:15:15:
- closedate changed to: "2004-03-08T03:15:15"
- closer changed to: "das"
- icomment:
Logged In: YES user_id=90580 thread safety in tclMacTime.c is not an issue as Mac Classic doesn't support pre-emptive threads... so I see no problem here. in any case, as Kenny said, the mac classic code will be removed from 8.5.x. Closing this as Invalid
- login: "das"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "das"