|
2016-03-22
| ||
| 20:30 | Factor out string internal rep definition so fix for [1af8de570511] is less awful. check-in: e99d66f317 user: dkf tags: trunk | |
| 20:30 | Factor out string internal rep definition so fix for [1af8de570511] is less awful. check-in: b3f2749a5c user: dkf tags: core-8-6-branch | |
|
2016-03-20
| ||
| 20:52 | • Ticket [1af8de5705] TEBC mishandled in string replace optimization ? statu... artifact: 197a8b153f user: dkf | |
| 20:43 | [1af8de570511] Fix crash in [string replace] caused by cut-n-paste. check-in: 7f8e2c6864 user: dkf tags: novem | |
| 20:43 | • Ticket [1af8de5705] TEBC mishandled in string replace optimization ? statu... artifact: 364f05c2c4 user: dkf | |
| 20:42 | [1af8de570511] Fix crash in [string replace] caused by cut-n-paste. check-in: 0d8edd300b user: dkf tags: trunk | |
| 20:41 | • Closed ticket [1af8de5705]: TEBC mishandled in string replace optimization ?</... artifact: a746b66508 user: dkf | |
| 20:40 | [1af8de570511] Fix crash in [string replace] caused by cut-n-paste. check-in: 5f1ea7ddc7 user: dkf tags: core-8-6-branch | |
| 18:20 | • Ticket [1af8de5705] TEBC mishandled in string replace optimization ? statu... artifact: 7ce6168816 user: dkf | |
|
2016-03-19
| ||
| 00:43 | • New ticket [1af8de5705]. artifact: eebaac8c77 user: bch | |
TEBC mishandled in [string replace] optimization ?
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.
Reproduced. This will be present in 8.6.5.
Fixed. Ended up adapting the code into this (the body of the test I'm using) because that avoids procedures and unnecessary puts calls.
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
And also applied to trunk.
The problem was not that the arguments to NEXT_INST_F were wrong (I've no 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 string 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.