Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-28
13:42 • Ticket [db4f2843cd] Sporadic segfault (BO) using tclIO status still Closed w... artifact: a4eb53a04d user: pooryorick
2019-08-28
14:42 • Closed ticket [fa6bf38d07]: Execution of byte-code with recompile in-between bre... artifact: 48154af919 user: sebres
2019-08-27
18:27
closes [fa6bf38d07]: integrate bug-fa6bf38d07-v2 check-in: 35c83160d6 user: sebres tags: core-8-6-branch
15:42 • Ticket [fa6bf38d07] Execution of byte-code with recompile in-between breaks norm... artifact: e8d99ff297 user: sebres
15:03 • Pending ticket [fa6bf38d07]. artifact: d1ce072aee user: sebres
15:00
fixes [fa6bf38d07]: command invocation (NRE callback to TEBCResume) caused by execution of recompile... closed check-in: a03e05de6e user: sebres tags: bug-fa6bf38d07
12:12 • Ticket [fa6bf38d07] Execution of byte-code with recompile in-between breaks norm... artifact: 70779b90fa user: sebres
12:03
added tests covering bug [fa6bf38d07] check-in: f7ece56ca2 user: sebres tags: bug-fa6bf38d07
11:11 • Ticket [fa6bf38d07] Execution of byte-code with recompile in-between breaks norm... artifact: 0c823c9bfd user: sebres
2019-08-26
19:58 • Ticket [fa6bf38d07]: 3 changes artifact: 1607a466bb user: dgp
17:01 • Ticket [fa6bf38d07]: 4 changes artifact: 674036341f user: sebres
15:41 • Ticket [fa6bf38d07]: 3 changes artifact: 59edf89f80 user: sebres
14:44 • Ticket [fa6bf38d07]: 3 changes artifact: 8978ea9d2b user: sebres
14:03 • Ticket [fa6bf38d07]: 3 changes artifact: 1dc600aad5 user: sebres
14:02 • New ticket [fa6bf38d07]. artifact: 3e1359e670 user: sebres

Execution of byte-code with recompile in-between breaks normal execution flow (e. g. disregards "return" or "break" commands).

Closed / Fixedfa6bf38d0728fbc7c7146f798ce0e3e35c70146cCreated 7 years agoUpdated 7 years ago
Descriptionwiki2019-08-26 14:02:29
Execution of byte-code after TEBC recompilation initiated from peephole breaks normal execution flow (e. g. disregards "return" or "break" commands) if some command or proc before would bump compiler epoch (cause recompile of a code in-between).

PoC:

set i [interp create]
$i eval {proc _recompile_ {} {rename set __set; rename __set set}}
$i eval {puts A;              puts B; return; puts C}
$i eval {puts A; _recompile_; puts B; return; puts C}

The last eval does not return before puts C.

Referenced by3
sebres Ticket [fa6bf38d07]: 3 changes [History diff]2019-08-26 14:03:31
sebreswiki2019-08-26 14:44:10

This is also not slave (interp-command) related issue, same with in main-interp within tclsh (compiled Tcl_RecordAndEval):

proc _recompile_ {} {rename set __set; rename __set set}
puts A; _recompile_; puts B; return; puts C
if 1 {puts A; _recompile_; puts B; return; puts C}
set i 0; while {[incr i] < 10} {puts A; _recompile_; puts B; return; puts C}
Just strange, the issue is not reproducible at all with eval, namespace eval/inscope ::, or if invoked like a proc.

sebreswiki2019-08-26 15:41:18

It looks like the issue is not restricted to "returnImm" instruction.
Trying to check command "break" issued with:

% set i 0; while {[incr i] < 10} { puts A; _recompile_; puts B; break; puts C }
A
B
invoked "break" outside of a loop"
As assumed it seems to be NRE (because 8.5 was not affected), so possibly [c718302fcab3892c] causes that (so ISC peephole, e. g. NRE-related switch to direct invocation, is implemented not correct, or it got broken later with some further commits).

sebres Ticket [fa6bf38d07]: 4 changes [History diff]2019-08-26 17:01:25
dgpplain2019-08-26 19:58:16
A piece of the puzzle is the special handling of exceptional return
codes when (interp->numLevels == 0).

The restarted evaluation of a recompile is probably not recreating
the same value of that field as the first pass.
sebreswiki2019-08-27 11:11:20

Sure, just I think it is rather an after effect (looks like a continuation with direct execution, resp. GetSrcInfoForPc() starts retriving from wrong current command)...
So for some reason in case of a while-loop (without a break), bumping of epoch causes "direct" execution starting from incr i, not by puts B. So it is called firstly after whole single iteration (while-body) is processed.

Also debugging of other cases shows strange continuation points in instStartCmdFailed.

sebreswiki2019-08-27 12:12:29

There is possibly a related issue [723a2f4ac3]

sebreswiki2019-08-27 15:03:40

Should be fixed now in branch bug-fa6bf38d07.

sebreswiki2019-08-27 15:42:26

After small review I provided another variant as bug-fa6bf38d07-v2, with a simplification (used the same "fixed" (and faster) code for INST_EVAL_STK).

sebres Closed ticket [fa6bf38d07]. [History diff]2019-08-28 14:42:08
Log in (anonymous is fine) to add a comment.