Expect: Unicode segmentation fault

From FVue
Jump to: navigation, search

Problem

The following script is giving me a Segmentation fault:

$ cat unicode.exp
spawn bash
send "aaébb"
expect -ex "aaébb" {send_user "PASS"}
$ expect -f unicode.exp
spawn bash
aaébbSegmentation fault

Witch strace the output is this:

$ strace expect -f unicode.exp
...
read(6, "aa\303\251bb", 4096)           = 6
brk(0x9f76000)                          = 0x9f76000
write(1, "aa\303\251bb", 6aaébb)             = 6
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

With `é' changed to `e', everything's all right:

$ cat unicode2.exp
spawn bash
send "aaebb"
expect -ex "aaebb" {send_user "PASS"}
$ strace expect -f unicode2.exp
...
write(1, "aaebb", 5aaebb)                    = 5
write(1, "PASS", 4PASS)                     = 4
...

dmesg reports this:

$ dmesg | tail -n1
[480309.512472] expect[23521]: segfault at 919f000 ip b75377e3 sp bfadd508 error 4 in libc-2.7.so[b74c0000+155000]

Environment

Environment (Ubuntu-10.04):

  • expect-5.44.1.14
  • tcl-8.4.19
  • bash-4.1.5
  • locale is set to "en_US.UTF-8"

Workaround 1

The problem does not occur when using expect-5.43.0.

Workaround 2

The problem does not occur when leaving out the -ex:

$ diff unicode.exp.orig unicode.exp
3c3
< expect -ex "aaébb" {send_user "PASS"}
---
> expect "aaébb" {send_user "PASS"}
$ expect -f unicode.exp
spawn bash
aaébbPASS

See this forum thread: What happened to Tcl and Expect - Rhinocerus

Workaround 3

Compile `expect' with latest sources and patch, see: http://sourceforge.net/tracker/index.php?func=detail&aid=3095935&group_id=13179&atid=31317

See also

Journal

2010-10-23

Expect unicode segmentation fault - comp.lang.tcl
Sent problem to comp.lang.tcl newsgroup

2010-10-27

The bug is being tackled :-), see: http://sourceforge.net/tracker/index.php?func=detail&aid=3095935&group_id=13179&atid=31317

Comments

blog comments powered by Disqus