From: SourceForge.net <no...@so...> - 2010-09-15 18:14:20
|
Bugs item #3067036, was opened at 2010-09-15 13:52 Message generated for change (Comment added) made by dgp You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3067036&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 12. ByteArray Object Group: development: 8.6b1.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Schelte Bron (sbron) Assigned to: Donal K. Fellows (dkf) Summary: Appending to 0-length byte array causes busy loop. Initial Comment: The code below goes into a busy loop with 100% cpu usage: set f [open /dev/null] chan configure $f -blocking 0 -translation binary set str [read $f 2] append str [binary format a* foo] The problem is in TclAppendBytesToByteArray(). This function tries to calculate the needed memory by doubling the currently allocated space until it is big enough. That method fails miserably when starting with an allocated space of size 0, as is the case in the code above. ---------------------------------------------------------------------- >Comment By: Don Porter (dgp) Date: 2010-09-15 14:14 Message: FWIW, I think it would be good to cover as many of these growth algorithms as possible with just one (set of) macro templates. ---------------------------------------------------------------------- Comment By: Andreas Kupries (andreas_kupries) Date: 2010-09-15 13:58 Message: Interesting. I remember seeing a different place where memory doubling was done which did things a bit differently: It doubled the length of the "requested" space, not the current one. As 'requested > allocated' this could never be 0. ... Remembering more, that was somewhere in appending to a list. I guess the "appending to string/bytearray" should be rewritten to the same scheme. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3067036&group_id=10894 |