assembler brought low by jumps, labels, and nops
Closed / Fixed7b32d8d13b0e0b3d999e3beb2cfdd866c1471b8fCreated 13 years agoUpdated 13 years ago
Descriptionplain2013-09-16 21:17:37
namespace path tcl::unsupported
append asm {push 0; label test; jumpTrue end; push 1; jump test;} [string repeat {nop;} 130] {label end}
proc demo {} [list assemble $asm]
puts working....
puts [disassemble proc demo]
puts done.
Referenced by1
7059c2ea37[7b32d8d13b] Insert missing field initialization. check-in2013-09-16 23:18:54
dgpplain2013-09-16 21:46:16
Well, I assumed it was the long jump, but the evidence says otherwise. Change the "130" value to "10" and it still segfaults.
dgpplain2013-09-16 22:01:20
setting the repeat count to 0, gets me:
working....
ByteCode 0x0x10087a910, refCt 1, epoch 15, interp 0x0x100849c10 (epoch 15)
Source "assemble {push 0; label test; jumpTrue end; push 1; jum"
Cmds 1, src 72, inst 11, litObjs 3, aux 0, stkDepth 1, code/src 0.00
Proc 0x0x1008b1f10, refCt 1, args 0, compiled locals 0
Commands 1:
1: pc 0-9, src 0-71
Command 1: "assemble {push 0; label test; jumpTrue end; push 1; jum"
(0) push1 0 # "0"
(2) jumpTrue1 +6 # pc 8
(4) push1 1 # "1"
(6) jump1 -4 # pc 2
(8) push1 2 # ""
(10) done
done.
Setting the count to just 1 (sticking in one "nop;")
brings it down.
dgpplain2013-09-16 22:11:35
paring away, I get a segfault from this:
tcl::unsupported::disassemble script {tcl::unsupported::assemble {
jump end; nop; label end
}}
dgpplain2013-09-16 22:43:12
Trouble is in BuildExceptionRanges() where a very very large value for maxCatchDepth is calculated.
dgpplain2013-09-16 22:51:04
...because bbPtr->catchDepth is not always properly initialized, it seems.
dgpplain2013-09-16 23:19:01
missing initialization committed to trunk.
dgpplain2013-09-16 23:25:34
...and that fixed it all. Yay!
Log in (anonymous is fine) to add a comment.