Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-04-12
11:51 • Closed ticket [42202ba1e5]: Coro inject followed by interp delete causes panic</... artifact: 749f266496 user: sebres
2017-04-04
14:14 • Ticket [42202ba1e5]: 3 changes artifact: 6da68c1d6d user: sebres
13:32 • Ticket [42202ba1e5]: 3 changes artifact: 732149d579 user: ferrieux
11:20 • Ticket [42202ba1e5]: 3 changes artifact: f11cd3a3f8 user: sebres
11:13
bug fix for [42202ba1e5ff566e0f9abb9f890e460fbc6c1c5c]: segfault by coro inject rewritten callback f... closed check-in: f700c69f46 user: sebres tags: fix-42202ba1e5ff566e
10:26 • Ticket [42202ba1e5] Coro inject followed by interp delete causes panic statu... artifact: 872b41f10c user: sebres
10:02 • Ticket [42202ba1e5]: 6 changes artifact: 7b00a4188c user: sebres
09:48
bug fix for [42202ba1e5ff566e0f9abb9f890e460fbc6c1c5c]: segfault by coro inject rewritten callback f... closed check-in: 4d97b416fd user: sebres tags: mistake
06:41 • Ticket [42202ba1e5] Coro inject followed by interp delete causes panic statu... artifact: f8bdcf27da user: ferrieux
02:09 • Ticket [42202ba1e5]: 3 changes artifact: c89b8ca48c user: apnadkarni
2017-03-30
14:37 • New ticket [42202ba1e5]. artifact: d71d82acf2 user: apnadkarni

Coro inject followed by interp delete causes panic

Closed / Fixed42202ba1e5ff566e0f9abb9f890e460fbc6c1c5cCreated 10 years agoUpdated 10 years ago
Descriptionplain2017-03-30 14:37:58
The following script causes Tcl_Panic with message:

DeleteInterpProc called with active evals

Script:

interp create slave
slave eval {
    coroutine demo apply {{} {
        while {1} yield
    }}
    demo
    tcl::unsupported::inject demo puts foo
}

interp delete slave

If the inject command is removed, the panic goes away. Since this happens with an unsupported command, keeping severity as minor but may be an indication of a more general problem. I was originally using inject interactively to figure out where one of the coroutines in a slave was getting stuck.
Referenced by2
  • f700c69f46bug fix for [42202ba1e5ff566e0f9abb9f890e460fbc6c1c5c]: segfault by coro inject rewritten callback for ::tcl::unsupported::inject, without leave the interpreter in unusable state (inaccurate environment exchange by adding eval callback), test covered now. check-in2017-04-04 11:13:36
  • 4d97b416fdbug fix for [42202ba1e5ff566e0f9abb9f890e460fbc6c1c5c]: segfault by coro inject rewritten callback for ::tcl::unsupported::inject, without leave the interpreter in unusable state (inaccurate environment exchange by adding eval callback), test covered now. check-in2017-04-04 09:48:21
apnadkarniplain2017-04-04 02:09:05
Note the given example does not call the coroutine after the injection. But that is irrelevant as the panic occurs even if the coroutine is called so the injection code gets a chance to run. For example

interp create slave
slave eval {
    coroutine demo apply {{} {
        while {1} yield
    }}
    demo
    tcl::unsupported::inject demo set x 1
    demo
}

interp delete slave
ferrieuxplain2017-04-04 06:41:41
Clearly there's a mismatched pair of (iPtr->numlevels++;iPtr->numlevels--).
I have yet to familiarize with the NR guts to know which one though.
The universe is colder without our beloved Miguel.
sebresplain2017-04-04 10:02:01
I've fixed it within [4d97b416fd94520d73090dfdc87753d31f1130d4].

There's not a mismatched pair of numlevels--/++. 
The way, that was used to add a inject-callback in the NRCoroInjectObjCmd is inaccurate (resp. not allowed anymore), because anyway can leave interpreter in unusable state after executing of the coro-resume callback.

BTW. For the people trying to tinker on NRE callbacks (I mean such hackish way's), please next time take care what you are doing.
sebresplain2017-04-04 10:26:57
Hmm... I have to be a bit familiar with fossil (pushed wrong test-branch).
Newer branch comming soon.
sebresplain2017-04-04 11:20:05
So I hope, now I've got correct branch :).

Fixed in [f700c69f46d57a2edca3b88f8026c54a42134fc2].

BTW, I need every now and then the routine I've called here `TclNREvalList` (for similar purposes as here).
We could possibly add this to our internal declarations in "tclInt.h"...
ferrieuxplain2017-04-04 13:32:39
Re the following comment by sebres:

"BTW. For the people trying to tinker on NRE callbacks (I mean such hackish way's), please next time take care what you are doing."

As it turns out, coroinject was contributed by Miguel himself.
Next time you feel you need to make acrid remarks, aim better.
sebresplain2017-04-04 14:14:27
> coroinject was contributed by Miguel himself.

I doubt, but I didn't want to blame someone...

> Next time you feel you need to make acrid remarks, aim better.

I would not have meant it so "angry". English is non-native for me, just foreigner :)
And most importantly I meant it in commemoration of him, for the sake of clarity.
Sorry, if that sounded too hard...
sebresplain2017-04-12 11:51:03
merged to 8.6
Log in (anonymous is fine) to add a comment.