Artifacts Associated With Ticket 1af8de570511f686
Ticket change [eebaac8c77] (rid 145721) by bch on 2016-03-19 00:43:51:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
This: proc p1 { val } { set ret "" for { set i 0 } { $i < $val } { incr i } { set ret [format "0%s" $ret] } return $ret } proc p2 { val } { return [string replace [p1 4] 1 1 $val] } puts [ set s [p2 x] ] Will cause a fault. I think I've tracked it to an optimization for inlining a [string replace] (if the string going in is same length as going out, optimized routine), and it appears the _effects_ can be eliminated by adjusting [/artifact/c36c352f54aa5c40?ln=5272] from calling NEXT_INST_F() with 1,1,1, versus 1,0,0. I am not versed in the inner workings of the compiler though, so will leave this for experts and watch with interest what discussions follow. - foundin initialized to: "abb9522f54"
- is_private initialized to: "0"
- login: "bch"
- priority initialized to: "5 Medium"
- private_contact initialized to: "0cf17391f69fcfd64bbde2b38bbfbb45c95439e6"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "bch"
- subsystem initialized to: "47. Bytecode Compiler"
- title initialized to: "TEBC mishandled in [string replace] optimization ?"
- type initialized to: "Bug"
Ticket change [7ce6168816] (rid 145723) by dkf on 2016-03-20 18:20:05:
- assignee changed to: "dkf"
- icomment: "Reproduced. This will be present in 8.6.5."
- login: "dkf"
- mimetype: "text/html"
- priority changed to: "9 Immediate"
- username: "dkf"
Ticket change [a746b66508] (rid 145728) by dkf on 2016-03-20 20:41:54:
- closedate changed to: "2457468.36243265"
- closer changed to: "dkf"
- icomment:
Fixed. Ended up adapting the code into this (the body of the test I'm using) because that avoids procedures and unnecessary <code>puts</code> calls. <pre> apply {{x y} { # Generate an unshared string value set val "" for { set i 0 } { $i < $x } { incr i } { set val [format "0%s" $val] } string replace $val[unset val] 1 1 $y }} 4 x </pre> - login: "dkf"
- mimetype: "text/html"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dkf"
Ticket change [364f05c2c4] (rid 145730) by dkf on 2016-03-20 20:43:08:
- closedate changed to: "2457468.36329394"
- icomment: "And also applied to <tt>trunk</tt>."
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
Ticket change [197a8b153f] (rid 145733) by dkf on 2016-03-20 20:52:21:
- closedate changed to: "2457468.36969845"
- icomment:
The problem was not that the arguments to <code>NEXT_INST_F</code> were wrong (I've <i>no</i> idea why that masked the error without giving wrong answers!) but rather that I was flushing the internal representation wrongly in one case. More strictly, I was applying the "right" flush to the wrong object, and this was a case in the code that wasn't tested; I'd cut-n-paste some code (doing a tricky bit of poking inside the internals of the <tt>string</tt> internal representation) from one place to just a little bit below without adjusting what variable it was applied to, and the complexity of the code made it too easy for the eye to slide over the problem without immediately seeing it. As part of the fix, I refactored the code so that the tricky bit is in a macro, making it easier for the reader to see that this sort of problem no longer exists.
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"