#66 crash with multiple interpreters

open
None
7
2009-09-25
2009-09-25
Donal K. Fellows
No

[09:24] <dihedral> child interps... think that will be a nogo
[09:25] <dihedral> we are using expect, which is not interp safe
[09:27] dkf (why isn't it interp-safe? that should be easy. no time to investigate though)
[09:27] <dihedral> just have seen tcl crashing due to badly mixing interps and expect
[09:28] <dihedral> it will crash as soon as you require expect in 2 interps

Discussion

    • priority: 5 --> 7
    • assigned_to: nobody --> andreas_kupries
     
  • Using expect in multiple interpreters

     
    Attachments
  • Tried to reproduce the problem using the attached script 'exmulti.tcl'.
    I see no crash.
    The output of the script on my system (linux-glibc2.3-ix86) is:

    Tcl 8.4.19
    Expect 5.44.1.14 (main)
    Sub-Interp interp0
    Expect 5.44.1.14 (sub)
    Wait 5
    Exit

    Please clarify (platform, version of expect, version of Tcl, demo script, did the demo script work with other versions of Expect and/or Tcl ?, ...).

     
  • (I'm just the messenger; it was dihedral who had the problem.)

     
  • I understand, and hope that dihedral will post more information here.

     
  • interesting, this time when i ran the code, tcl did not crash on me, however
    the second interp does not have the channels expect opens on package require!

     
  • Evan
    Evan
    2009-10-07

    I experience tcl crashing when I require Expect in more than one thread. Unfortunate as I want to make a multithread Expect application.

     
  • idleminds, are you able to provide more information, i.e. version of Expect, version of Tcl, and a Tcl script demonstrating the crash ?

     
  • Evan
    Evan
    2009-10-07

    I don't see how to attach an additional file. Here is my script. Expect 5.43, Tcl 8.5.7, Win 32 XP. Comment out package require Expect lines and script behaves as expected.

    package require Thread

    proc listen { msg } {
    puts "$msg"
    }

    set child1 [thread::create {
    package require Expect
    proc talk { id } {
    thread::send -async $id [list listen "hello from child1"]
    }
    thread::wait
    }]

    set child2 [thread::create {
    package require Expect
    proc talk { id } {
    thread::send -async $id [list listen "hello from child2"]
    }
    thread::wait
    }]

    set id [thread::id]
    thread::send -async $child1 [list talk $id]
    thread::send -async $child2 [list talk $id]
    thread::wait

     
  • Ok. Given this info it seems that this is ActiveTcl and ActiveState's Expect for Windows. Can you confirm ? Because that would be a completely different code base than the sources in this project (which is the Unix Expect).

     
  • Evan
    Evan
    2009-10-07

    Yes, activestate. I just tried linux as well which crashes with tcl 8.4 but not on 8.5. I guess I will be moving to linux.

     
  • Evan
    Evan
    2009-10-07

    Actually, I'm trying linux again and it is crashing. I often get different results with it executing as expected a small portion of the time. Does the script I posted work for you?

     
  • Haven't tried yet, was looking for the Expect4Win sources ...
    Put it on my todo however. Having the script should help.

     
  • Evan
    Evan
    2009-10-07

    Ah, perhaps it is a moot point anyways because as I understand it Expect isn't thread safe to begin with. So I'm not sure if my example should even work in the first place.