Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Segmentation Fault' while debugging expect script

I am debugging an expect program with the traditional debugging way by passing the -D 1 flag for the following script.

#!/usr/bin/expect
proc p3 {} {
        set m 0
}
proc p2 {} {
        set c 4
        p3
        set d 5
}
proc p1 {} {
        set a 2
        p2
        set a 5
}
p1

With the debugger command w, I am trying to see the stack frame and got the following error.

dinesh@mypc:~/pgms/expect$ expect -D 1 stack.exp 
1: proc p3 {} {
    set m 0 
}

dbg1.0> n
1: proc p2 {} {
    set c 4
    p3
    set d 5
}

dbg1.1> 
1: proc p1 {} {
    set a 2
    p2
    set a 5
}

dbg1.2> 
1: p1

dbg1.3> s
2: set a 2
dbg2.4> 
2: p2
dbg2.5> 
3: set c 4
dbg3.6> w
 0: expect {-D} {1} {stack.exp}
Segmentation fault (core dumped)
dinesh@mypc:~/pgms/expect$ 

I am having the expect version 5.45.

Is there anything wrong in my way of command execution ?

like image 530
Dinesh Avatar asked Jul 27 '26 15:07

Dinesh


1 Answers

In order to achieve the debugging trace, Expect pokes its fingers inside the implementation of Tcl. In particular, it has copies of the definitions of some of the internal structures used inside Tcl (e.g., the definition of the implementation of procedures and of stack frames). However, these structures change from time to time; we don't announce such internal implementation changes, as they shouldn't have any bearing on any other code, but that's obviously not the case.

Overall, this is a bug in Expect (and it might be that the fix is for a new C API function to be added to Tcl). In order to see about fixing this, we need to know not just the exact version of Expect but also the exact version of Tcl (use info patchlevel to get this).

like image 102
Donal Fellows Avatar answered Jul 30 '26 04:07

Donal Fellows



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!