View Ticket
Not logged in
Ticket UUID: 42202ba1e5ff566e0f9abb9f890e460fbc6c1c5c
Title: Coro inject followed by interp delete causes panic
Type: Code_Defect Version: >= 8.6
Submitter: apnadkarni Created on: 2017-03-30 14:37:58
Subsystem: 60. NRE and coroutines Assigned To: nobody
Priority: Immediate Severity: Severe
Status: Closed Last Modified: 2017-04-12 11:51:03
Resolution: Fixed Closed By: nobody
    Closed on:
Description:
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.
User Comments: sebres added on 2017-04-12 11:51:03:
merged to 8.6

sebres added on 2017-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...

ferrieux added on 2017-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.

sebres added on 2017-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"...

sebres added on 2017-04-04 10:26:57:
Hmm... I have to be a bit familiar with fossil (pushed wrong test-branch).
Newer branch comming soon.

sebres added on 2017-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.

ferrieux added on 2017-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.

apnadkarni added on 2017-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