Artifacts Associated With Ticket 272e866f1e
Ticket change [1bd98c743c] (rid 135582) by gustafn on 2013-11-12 19:05:42:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
When reading a file with e.g. 1.1 GB via set content [read $f] Tcl crashes due to the doubling policy of reallocs on machines where sizeof(int) == 32 (which is as well the case on 64 bit Linux). Due to doubling the length of the buffer, the length variable of type "int" becomes negative on values larger than 1GB. While one can discuss the usefulness of reading large files into memory, the situation can be improved quite easily by limiting the doubling policy to 2GB (actually INT_MAX). The problem happened in a Tcl-based zip-file generator, when the size of a single file is larger than 1.x GB. A sample patch is available (I assume i can attach the patch after writing the ticket). Most probably there are more places in Tcl, where a similar patch might be useful.
- foundin initialized to: "8.5.15"
- is_private initialized to: "0"
- login: "gustafn"
- priority initialized to: "5 Medium"
- private_contact initialized to: "d0ad4471e07e8c03bf0d90786ec6d31e33bcf241"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "gustafn"
- subsystem initialized to: "25. Channel System"
- title initialized to: "Crash when reading a file of e.g 1.1 GB"
- type initialized to: "Bug"
Add attachment "tclI-2GB.patch" [5ad002f73f] (rid 135583) by gustafn on 2013-11-12 19:07:45.
Ticket change [defac9d228] (rid 135591) by dkf on 2013-11-14 22:27:26:
- assignee changed to: "dgp"
- icomment: "dgp has worked on limits…"
- login: "dkf"
- mimetype: "text/html"
- priority changed to: "8"
- username: "dkf"
Ticket change [a2926849b1] (rid 135787) by dgp on 2013-12-03 15:24:52:
- icomment:
We've tidied up many overflow scenarios but apparently not this one. Similar trouble may lurk in ReadChars()
- login: "dgp"
- mimetype: "text/plain"
- title changed to: "Uncontrolled overflow in ReadBytes()"
- icomment:
Ticket change [6cabaa4725] (rid 135788) by dgp on 2013-12-03 15:44:26:
- icomment:
The fix for the analogous problem in ReadChars() was made in checkin http://core.tcl.tk/tcl/info/cdf00220922c7d8d so it's been good since 8.5.8. The ticket covering the development of that change is http://core.tcl.tk/tcl/info/2107634 Looks like we just need the analogous fix put in place for binary channels.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e8b7ae7e2f] (rid 135926) by gustafn on 2013-12-09 15:27:53:
- icomment:
yep, using Tcl_AttemptSetObjLength() seems better, although the function is quite complex. i would prefer a function Tcl_GrowObjLength(... desired_length, required_min_length) to keep the changes mininmal and to encapsulate the growing behavior.
- login: "gustafn"
- mimetype: "text/plain"
- icomment:
Ticket change [a2f106f10b] (rid 135927) by gustafn on 2013-12-09 15:28:16:
- icomment:
yep, using Tcl_AttemptSetObjLength() seems better, although the function is quite complex. i would prefer a function Tcl_GrowObjLength(... desired_length, required_min_length) to keep the changes mininmal and to encapsulate the growing behavior.
- login: "gustafn"
- mimetype: "text/plain"
- icomment:
Ticket change [73f87bf9b6] (rid 136468) by dgp on 2014-01-15 20:22:13:
- icomment: "See branch bug-272e866f1e for a possible fix."
- login: "dgp"
- mimetype: "text/plain"
Ticket change [ed5fe63eb4] (rid 136474) by dkf on 2014-01-16 22:42:43:
- icomment:
Patch seems reasonable, but removing the stuff currently elided with <tt>#if 0</tt> is better practice. We have fossil to keep the history of bad ideas for us now!
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
- icomment:
Ticket change [b7005323d5] (rid 137566) by gustafn on 2014-04-10 14:35:37:
- icomment:
We tested the the patches on the mentioned branch in tcl8.5, and everything seems to work fine. We had to copy/paste manually some macro definitions on generic/tclInt.h and the function TclAppendBytesToByteArray which were introduced on tcl 8.6.
- login: "gustafn"
- mimetype: "text/plain"
- icomment:
Ticket change [ad5d81cdfe] (rid 138020) by dgp on 2014-05-08 17:49:52:
- closedate changed to: "2456786.24297155"
- closer changed to: "dgp"
- icomment: "This is fixed on trunk and core-8-5-branch now."
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"