TkText freezes

Q

quillion

Hello all,

Running On i686 Linux

Pulled this code out from another app

------------------------------------------------
#! /usr/bin/env ruby
# #! /usr/local/bin/ruby

require 'tk'
# Overriding insert in Tktext

class HiText < TkText
# remove any bindings that get in the way
# self.bind_remove "Control-k"

def insert(index,char,tag1,tag2)
# set char to preference
if char =~/[A-Z]/
flag = super(index,char,tag2)
elsif
char =~ /[a-z]/
flag = super(index,char,tag1)
end
end
end

root = TkRoot.new
edit = HiText.new(root) {
width 50
height 10
pack
focus
}

# set tags to whatever... colours styles etc
col2 = TkTextTag.new(edit, 'foreground'=>'red')
col1 = TkTextTag.new(edit, 'foreground'=>'blue')

root.title 'HiText : Control-d exits'

edit.bind("KeyPress") { |event|
Tk.callback_break if edit.insert('insert', event.char, col1, col2)
}

edit.bind "Control-d", proc{root.destroy}
Tk.mainloop
------------------------------------------------------------------------
Is there a better way of doing this ?

I have been using this method for some years with Tk but now find it
freezing with ruby 1.8.1 (2003-12-05) [i686-linux and in the full app
will sometimes segfault and dump core. Works ok with a snapshot from
October ruby 1.8.0 (2003-10-02) [i686-linux]

/usr/local/lib/ruby/1.8/tk.rb:762: [BUG] Segmentation fault
ruby 1.8.1 (2003-12-05) [i686-linux]

Happy Christmas and the best New Year to all

neil
 
T

ts

q> /usr/local/lib/ruby/1.8/tk.rb:762: [BUG] Segmentation fault
q> ruby 1.8.1 (2003-12-05) [i686-linux]

Can you run it under gdb and give the backtrace when it crash ?

For me, it seems to crash in a Tk function : perhaps this means that
the problem is in libtcltk and not in ruby ???


Guy Decoux
 
Q

quillion

ts said:
q> /usr/local/lib/ruby/1.8/tk.rb:762: [BUG] Segmentation fault
q> ruby 1.8.1 (2003-12-05) [i686-linux]

Can you run it under gdb and give the backtrace when it crash ?

For me, it seems to crash in a Tk function : perhaps this means that
the problem is in libtcltk and not in ruby ???


Guy Decoux

The program will not accept keystrokes when attached to gdb
but I may be doing this incorrectly, I'm no expert in this.
gdb core file produces ( of limited use )


warning: core file may not match specified executable file.

Core was generated by `/usr/local/bin/ruby -w /home/neil/bin/ruple'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so...done.
Loaded symbols for /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so
Reading symbols from /usr/lib/libtk8.4.so...done.
Loaded symbols for /usr/lib/libtk8.4.so
Reading symbols from /usr/lib/libtcl8.4.so...done.
Loaded symbols for /usr/lib/libtcl8.4.so
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Loaded symbols for /usr/X11R6/lib/libX11.so.6
Reading symbols from /usr/local/lib/ruby/1.8/i686-linux/tkutil.so...done.
Loaded symbols for /usr/local/lib/ruby/1.8/i686-linux/tkutil.so
Reading symbols from
/usr/X11R6/lib/X11/locale/lib/common/xlcDef.so.2...done.
Loaded symbols for /usr/X11R6/lib/X11/locale/lib/common/xlcDef.so.2
Reading symbols from /usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2...done.
Loaded symbols for /usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2
Reading symbols from /usr/lib/gconv/ISO8859-1.so...done.
Loaded symbols for /usr/lib/gconv/ISO8859-1.so
Reading symbols from /usr/X11R6/lib/libXcursor.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXcursor.so.1
Reading symbols from /usr/X11R6/lib/libXrender.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXrender.so.1
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Loaded symbols for /usr/X11R6/lib/libXext.so.6
#0 0x4009bd71 in kill () from /lib/i686/libc.so.6

Neil
 
T

ts

q> The program will not accept keystrokes when attached to gdb

Well, here an example (~/b.rb is the example that you have posted)

svg% gdb ruby
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) set li 32
(gdb) r ~/b.rb
Starting program: /home/ts/ruby/ruby-1.8.1/ruby ~/b.rb

Program received signal SIGSEGV, Segmentation fault.

[[ it crash on the second keystroke ]]

0x42074bd0 in _int_free () from /lib/i686/libc.so.6
(gdb) bt
#0 0x42074bd0 in _int_free () from /lib/i686/libc.so.6
#1 0x42075a5c in free () from /lib/i686/libc.so.6
#2 0x4027f403 in TclpFree () from /usr/lib/libtcl.so.0
#3 0x40284153 in Tcl_Free () from /usr/lib/libtcl.so.0
#4 0x401dcfc2 in Tk_FreeGC () from /usr/lib/libtk.so.0
#5 0x4023f5f8 in FreeStyle () from /usr/lib/libtk.so.0
#6 0x4023fd7e in LayoutDLine () from /usr/lib/libtk.so.0
#7 0x4023ffc8 in UpdateDisplayInfo () from /usr/lib/libtk.so.0
#8 0x402433cc in TkTextPixelIndex () from /usr/lib/libtk.so.0
#9 0x402485e6 in TkTextPickCurrent () from /usr/lib/libtk.so.0
#10 0x4024114c in DisplayText () from /usr/lib/libtk.so.0
#11 0x402c4319 in TclServiceIdle () from /usr/lib/libtcl.so.0
#12 0x402b6672 in Tcl_DoOneEvent () from /usr/lib/libtcl.so.0
#13 0x400169f0 in lib_eventloop_core (check_root=1, check_var=0x0)
at tcltklib.c:426
#14 0x40016cf1 in lib_eventloop_main (check_rootwidget=2) at tcltklib.c:520
#15 0x0805a60d in rb_ensure (b_proc=0x40016cc4 <lib_eventloop_main>, data1=2,
e_proc=0x40016d04 <lib_eventloop_ensure>, data2=0) at eval.c:4717
#16 0x40016e79 in lib_eventloop_launcher (check_rootwidget=2) at tcltklib.c:555
#17 0x40016edc in lib_mainloop (argc=1, argv=0xbfffec20, self=1075273536)
at tcltklib.c:576
#18 0x080653f7 in call_cfunc (func=0x40016e9c <lib_mainloop>, recv=1075273536,
len=109051920, argc=1, argv=0x42138c80) at eval.c:4929
#19 0x0805af55 in rb_call0 (klass=1075273296, recv=1075273536, id=10353,
oid=2, argc=1, argv=0xbfffec20, body=0x40175e3c, nosuper=0) at eval.c:5066
#20 0x0805b73d in rb_call (klass=1075273296, recv=1075273536, mid=10353,
argc=1, argv=0xbfffec20, scope=0) at eval.c:5287
#21 0x08056e81 in rb_eval (self=1075264456, n=0x2) at eval.c:3078
#22 0x0805b23e in rb_call0 (klass=1075270816, recv=1075264456, id=10353,
oid=2, argc=0, argv=0x0, body=0x4007f670, nosuper=0) at eval.c:5194
#23 0x0805b73d in rb_call (klass=1075270816, recv=1075264456, mid=10353,
argc=0, argv=0x0, scope=0) at eval.c:5287
#24 0x08056e81 in rb_eval (self=1074436664, n=0x2) at eval.c:3078
#25 0x0805385c in ruby_exec () at eval.c:1436
#26 0x0805389d in ruby_run () at eval.c:1457
#27 0x08051d79 in main () at main.c:50
#28 0x420158f7 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)

(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/ts/ruby/ruby-1.8.1/ruby ~/b.rb

Program received signal SIGSEGV, Segmentation fault.
0x3030772e in ?? ()
(gdb) bt
#0 0x3030772e in ?? ()
#1 0x4023ffc8 in UpdateDisplayInfo () from /usr/lib/libtk.so.0
#2 0x402433cc in TkTextPixelIndex () from /usr/lib/libtk.so.0
#3 0x402485e6 in TkTextPickCurrent () from /usr/lib/libtk.so.0
#4 0x4024114c in DisplayText () from /usr/lib/libtk.so.0
#5 0x402c4319 in TclServiceIdle () from /usr/lib/libtcl.so.0
#6 0x402b6672 in Tcl_DoOneEvent () from /usr/lib/libtcl.so.0
#7 0x400169f0 in lib_eventloop_core (check_root=1, check_var=0x0)
at tcltklib.c:426
#8 0x40016cf1 in lib_eventloop_main (check_rootwidget=2) at tcltklib.c:520
#9 0x0805a60d in rb_ensure (b_proc=0x40016cc4 <lib_eventloop_main>, data1=2,
e_proc=0x40016d04 <lib_eventloop_ensure>, data2=0) at eval.c:4717
#10 0x40016e79 in lib_eventloop_launcher (check_rootwidget=2) at tcltklib.c:555
#11 0x40016edc in lib_mainloop (argc=1, argv=0xbfffec20, self=1075273536)
at tcltklib.c:576
#12 0x080653f7 in call_cfunc (func=0x40016e9c <lib_mainloop>, recv=1075273536,
len=136699464, argc=1, argv=0x0) at eval.c:4929
#13 0x0805af55 in rb_call0 (klass=1075273296, recv=1075273536, id=10353,
oid=2, argc=1, argv=0xbfffec20, body=0x40175e3c, nosuper=0) at eval.c:5066
#14 0x0805b73d in rb_call (klass=1075273296, recv=1075273536, mid=10353,
argc=1, argv=0xbfffec20, scope=0) at eval.c:5287
#15 0x08056e81 in rb_eval (self=1075264456, n=0x2) at eval.c:3078
#16 0x0805b23e in rb_call0 (klass=1075270816, recv=1075264456, id=10353,
oid=2, argc=0, argv=0x0, body=0x4007f670, nosuper=0) at eval.c:5194
#17 0x0805b73d in rb_call (klass=1075270816, recv=1075264456, mid=10353,
argc=0, argv=0x0, scope=0) at eval.c:5287
#18 0x08056e81 in rb_eval (self=1074436664, n=0x2) at eval.c:3078
#19 0x0805385c in ruby_exec () at eval.c:1436
#20 0x0805389d in ruby_run () at eval.c:1457
#21 0x08051d79 in main () at main.c:50
#22 0x420158f7 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)


but I know nothing about Tcl/Tk



Guy Decoux
 
Q

quillion

ts said:
q> The program will not accept keystrokes when attached to gdb

Well, here an example (~/b.rb is the example that you have posted)

svg% gdb ruby
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) set li 32
(gdb) r ~/b.rb
Starting program: /home/ts/ruby/ruby-1.8.1/ruby ~/b.rb
cut ...

thanks still wont run i'll work on it

but under ruby -d get

tcltklib: rb_eval_string(TkCore.callback %Q!c00099 1047 ?? ?? ?? ?? ??
?? 0x2000032 40 ?? ?? ?? 16 1765335 ?? 31 -5d ?? 40 0 d 100 0x00007d
00000000 2 .w00001 227 90!)
Exception `RuntimeError' at /usr/local/lib/ruby/1.8/tk.rb:780 - check
backtrace
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
[".w00001", "insert", "insert", "d", "tag00000"]
=> ".w00001 insert insert d tag00000"
tcltklib: invoke from current eventloop 401d0928
tcltklib: invoke_real called by thread:401d0928
tcltklib: call Tcl_GetCommandInfo, .w00001
tcltklib: end Tcl_GetCommandInfo
==> ""

and

Exception `TkCallbackBreak' at /usr/local/lib/ruby/1.8/tk.rb:789 -
/usr/local/lib/ruby/1.8/tk.rb:789:in `callback'
/usr/local/lib/ruby/1.8/tk.rb:762:in `callback_break': Tk callback
returns 'break' status (TkCallbackBreak)
from ./ruple-0.52.rb:3915
from ./ruple-0.52.rb:3897:in `call'
from /usr/local/lib/ruby/1.8/tk.rb:524:in `eval_cmd'
from /usr/local/lib/ruby/1.8/tk.rb:524:in `install_bind'
from /usr/local/lib/ruby/1.8/tk.rb:523:in `call'
from /usr/local/lib/ruby/1.8/tk.rb:731:in `eval_cmd'
from /usr/local/lib/ruby/1.8/tk.rb:731:in `cb_eval'
from /usr/local/lib/ruby/1.8/tk.rb:699:in `call'
from /usr/local/lib/ruby/1.8/tk.rb:786:in `callback'
tcltklib: (rb_eval_string result) failed
tcltklib: thread scheduling
tcltklib: no other thread
tcltklib: thread scheduling

neil
 
Q

quillion

quillion said:
cut ...

thanks still wont run i'll work on it

got it running under gdb cannot get it to segfault
but get the same as under debug

["update"]
=> "update"
tcltklib: invoke from current eventloop 401d0928
tcltklib: invoke_real called by thread:401d0928
tcltklib: call Tcl_GetCommandInfo, update
tcltklib: end Tcl_GetCommandInfo
tcltklib: rb_eval_string(TkCore.callback %Q!c00070 8980 ?? ?? ?? ?? ??
?? 0x2a00032 67 ?? ?? ?? 16 2683329 ?? 19 -8 \{} ?? 67 0 F1 65470
0x00007d 00000000 2 .w00001 254 110!)
Exception `RuntimeError' at /usr/local/lib/ruby/1.8/tk.rb:780 - check
backtrace
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
Exception `ArgumentError' at /usr/local/lib/ruby/1.8/tk.rb:232 - invalid
value for Number:"??"
tcltklib: (rb_eval_string result)
tcltklib: Tcl_AppendResult
tcl

Oh my it's christmas eve grand children here what am I doing :(

Neil
 
T

ts

q> got it running under gdb cannot get it to segfault

Well, under gdb don't run it with -d (it's important because this can slow
down ruby) and try to press key very quickly.

Apparently it's easier to have a segfault with a "fast" PC (or you must
have a stupid PC like svg to see the problem :))


Guy Decoux
 
Y

Yukihiro Matsumoto

Hi,

In message "TkText freezes"

|I have been using this method for some years with Tk but now find it
|freezing with ruby 1.8.1 (2003-12-05) [i686-linux and in the full app
|will sometimes segfault and dump core. Works ok with a snapshot from
|October ruby 1.8.0 (2003-10-02) [i686-linux]

Currently I suspect this is caused by LinuxThread bug. I tried hard
to solve Nathaniel Talbott's problem, which must be caused by the
same reason, but I couldn't make complete success.

Can you give us the information about your libpthread version? You
must using LinuxThread included in glibc, so that glibc version will
do. Mine was glibc-2.3.2.ds1-10 on Debian/sid.

Of course, it's better to be proven that my suspicion is wrong, since
it's a lot easier to fix bugs in Ruby. If you have any information
about this problem, let me know.

The only workaround I know for sure is use libraries compiled without
-lpthread, if possible.

matz.
 
Q

quillion

ts said:
q> got it running under gdb cannot get it to segfault

Well, under gdb don't run it with -d (it's important because this can slow
down ruby) and try to press key very quickly.

Apparently it's easier to have a segfault with a "fast" PC (or you must
have a stupid PC like svg to see the problem :))


Guy Decoux
Thanks Guy you have been most helpfull, my Penetium II is slow by todays
standards :) finally managed this,

Program received signal SIGSEGV, Segmentation fault.
0x400e6379 in mallopt () from /lib/i686/libc.so.6
(gdb) r ruple
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/local/bin/ruby ruple

Program received signal SIGSEGV, Segmentation fault.
st_free_table (table=0x81a65e8) at st.c:219
219 next = ptr->next;
(gdb) bt
#0 st_free_table (table=0x81a65e8) at st.c:219
#1 0x0806c009 in gc_sweep () at gc.c:985
#2 0x0806c5a0 in rb_gc () at gc.c:1351
#3 0x0806b385 in rb_newobj () at gc.c:350
#4 0x080a6eba in str_alloc (klass=1075652732) at string.c:45
#5 0x080a6f1f in str_new (klass=1075652732,
ptr=0x83e57f6 "%b %c %d %f %h %i %k %m %o %p %s %t %w %x %y %A %B
%D %E %K %N %R %S %T %W %X %Y", len=2)
at string.c:67
#6 0x080a7b63 in rb_str_substr (str=1075890756, beg=1075446760,
len=138303472) at string.c:534
#7 0x080ab410 in rb_str_split_m (argc=1, argv=0xbfff7550,
str=1075890756) at string.c:2642
#8 0x080669d9 in call_cfunc (func=0x80ab140 <rb_str_split_m>,
recv=1075890756, len=136448568, argc=1,
argv=0xbfff7550) at eval.c:4900
#9 0x0805bf62 in rb_call0 (klass=1075652732, recv=1075890756, id=4441,
oid=1075652732, argc=1, argv=0xbfff7550,
body=0x401d214c, nosuper=0) at eval.c:5037
#10 0x0805c292 in rb_call (klass=1075652732, recv=1075890756, mid=4441,
argc=1, argv=0xbfff7550, scope=0)
at eval.c:5258
#11 0x08056057 in rb_eval (self=1076049104, n=0x401d287c) at ruby.h:627
#12 0x08055e86 in rb_eval (self=1076049104, n=0x401d287c) at eval.c:3047
#13 0x08058b42 in rb_eval (self=1076049104, n=0x401d287c) at eval.c:2773
#14 0x0805bd33 in rb_call0 (klass=1076049024, recv=1076049104, id=15137,
oid=1075652732, argc=0, argv=0xbfff89d8,
body=0x40297e6c, nosuper=0) at eval.c:5165
#15 0x0805c292 in rb_call (klass=1076049024, recv=1076049104, mid=15137,
argc=2, argv=0xbfff89d0, scope=0)
at eval.c:5258
#16 0x08056057 in rb_eval (self=1076024764, n=0x401d287c) at ruby.h:627
#17 0x08057bfe in rb_eval (self=1076024764, n=0x401d287c) at eval.c:2828
#18 0x08058167 in rb_eval (self=1076024764, n=0x401d287c) at eval.c:3030
#19 0x08058517 in rb_eval (self=1076024764, n=0x401d287c) at eval.c:3368
#20 0x0805a1e8 in rb_yield_0 (val=1076060384, self=1076024764, klass=0,
flags=1, avalue=2) at eval.c:4270
#21 0x08060557 in proc_invoke (proc=1080044500, args=1076060384, self=6,
klass=1076060384) at ruby.h:627
#22 0x08060686 in proc_call (proc=1080044500, args=1076060384) at
eval.c:7197
#23 0x080669d9 in call_cfunc (func=0x8060670 <proc_call>,
recv=1080044500, len=136448568, argc=29, argv=0x83e63f0)
at eval.c:4900
#24 0x0805bf62 in rb_call0 (klass=1075599292, recv=1080044500, id=5193,
oid=1076060384, argc=29, argv=0x83e63f0,
body=0x401c5730, nosuper=0) at eval.c:5037
#25 0x0805c292 in rb_call (klass=1075599292, recv=1080044500, mid=5193,
argc=29, argv=0x83e63f0, scope=1)
at eval.c:5258
#26 0x0805c5c9 in rb_funcall2 (recv=1076060384, mid=5193, argc=29,
argv=0x83e63f0) at ruby.h:627
#27 0x080541d6 in rb_eval_cmd (cmd=1080044500, arg=1075446760, tcheck=0)
at eval.c:1614
#28 0x402cc981 in tk_eval_cmd (argc=30, argv=0xbfffabb0) at tkutil.c:21
#29 0x080669d9 in call_cfunc (func=0x402cc940 <tk_eval_cmd>,
recv=1076058664, len=136448568, argc=30,
argv=0xbfffabb0) at eval.c:4900
#30 0x0805bf62 in rb_call0 (klass=1076058324, recv=1076058664, id=15665,
oid=5193, argc=30, argv=0xbfffabb0,
body=0x40235898, nosuper=0) at eval.c:5037
#31 0x0805c292 in rb_call (klass=1076058324, recv=1076058664, mid=15665,
argc=30, argv=0xbfffabb0, scope=0)
at eval.c:5258

Neil
 
Q

quillion

Yukihiro said:
Hi,

In message "TkText freezes"

|I have been using this method for some years with Tk but now find it
|freezing with ruby 1.8.1 (2003-12-05) [i686-linux and in the full app
|will sometimes segfault and dump core. Works ok with a snapshot from
|October ruby 1.8.0 (2003-10-02) [i686-linux]

Currently I suspect this is caused by LinuxThread bug. I tried hard
to solve Nathaniel Talbott's problem, which must be caused by the
same reason, but I couldn't make complete success.

Can you give us the information about your libpthread version? You
must using LinuxThread included in glibc, so that glibc version will
do. Mine was glibc-2.3.2.ds1-10 on Debian/sid.

Of course, it's better to be proven that my suspicion is wrong, since
it's a lot easier to fix bugs in Ruby. If you have any information
about this problem, let me know.

The only workaround I know for sure is use libraries compiled without
-lpthread, if possible.

matz.

My glibc is glibc-2.3.2-14mdk on mandrake 9.2 I have a mandrake 9.0
I can boot into I'll try that

Neil
 
Q

quillion

quillion said:
Yukihiro said:
Hi,

In message "TkText freezes"

|I have been using this method for some years with Tk but now find it
|freezing with ruby 1.8.1 (2003-12-05) [i686-linux and in the full app
|will sometimes segfault and dump core. Works ok with a snapshot from
|October ruby 1.8.0 (2003-10-02) [i686-linux]

Currently I suspect this is caused by LinuxThread bug. I tried hard
to solve Nathaniel Talbott's problem, which must be caused by the
same reason, but I couldn't make complete success.

Can you give us the information about your libpthread version? You
must using LinuxThread included in glibc, so that glibc version will
do. Mine was glibc-2.3.2.ds1-10 on Debian/sid.

Of course, it's better to be proven that my suspicion is wrong, since
it's a lot easier to fix bugs in Ruby. If you have any information
about this problem, let me know.

The only workaround I know for sure is use libraries compiled without
-lpthread, if possible.

matz.

My glibc is glibc-2.3.2-14mdk on mandrake 9.2 I have a mandrake 9.0
I can boot into I'll try that

Neil

On Mandrake 9.0 glibc-2.2.5-16mdk seg faults far easier on second key
press rather than freezing. bt below
Thanks very much for the advice, I feel rather honoured :))

Program received signal SIGSEGV, Segmentation fault.
0x400e4427 in malloc () from /lib/i686/libc.so.6
(gdb) bt
#0 0x400e4427 in malloc () from /lib/i686/libc.so.6
#1 0x400e4262 in malloc () from /lib/i686/libc.so.6
#2 0x403961df in TclpAlloc () from /usr/lib/libtcl8.3.so
#3 0x4039ac4e in Tcl_Alloc () from /usr/lib/libtcl8.3.so
#4 0x4035b492 in TkTextCharLayoutProc () from /usr/lib/libtk8.3.so
#5 0x40357b8f in TkTextFreeDInfo () from /usr/lib/libtk8.3.so
#6 0x4035806d in TkTextFreeDInfo () from /usr/lib/libtk8.3.so
#7 0x4035b009 in TkTextPixelIndex () from /usr/lib/libtk8.3.so
#8 0x403601a1 in TkTextPickCurrent () from /usr/lib/libtk8.3.so
#9 0x40358fde in TkTextFreeDInfo () from /usr/lib/libtk8.3.so
#10 0x403d964b in TclServiceIdle () from /usr/lib/libtcl8.3.so
#11 0x403cbf08 in Tcl_DoOneEvent () from /usr/lib/libtcl8.3.so
#12 0x40015b49 in lib_eventloop_core (check_root=1, check_var=0x0) at
tcltklib.c:426
#13 0x40015e60 in lib_eventloop_main (check_rootwidget=2) at tcltklib.c:520
#14 0x0805aa5a in rb_ensure (b_proc=0x40015e30 <lib_eventloop_main>,
data1=2,
e_proc=0x40015e80 <lib_eventloop_ensure>, data2=0) at eval.c:4694
#15 0x40016008 in lib_eventloop_launcher (check_rootwidget=2) at
tcltklib.c:555
#16 0x40016073 in lib_mainloop (argc=1, argv=0xbfffe690, self=1076020976) at
tcltklib.c:576
#17 0x080661d6 in call_cfunc (func=0x40016030 <lib_mainloop>,
recv=1076020976, len=135944632, argc=1,
argv=0x4018e690) at eval.c:4900
#18 0x0805b41f in rb_call0 (klass=1076020196, recv=1076020976,
id=14393,
oid=2, argc=1, argv=0xbfffe690,
body=0x4022c358, nosuper=0) at eval.c:5037
#19 0x0805bc47 in rb_call (klass=1076020196, recv=1076020976,
mid=14393,
argc=1, argv=0xbfffe690, scope=0)
at eval.c:5258
#20 0x080570dd in rb_eval (self=1075972236, n=0x2) at eval.c:3055
#21 0x0805b70f in rb_call0 (klass=1076005056, recv=1075972236,
id=14393,
oid=2, argc=0, argv=0x0, body=0x4027dc08,
nosuper=0) at eval.c:5165
#22 0x0805bc47 in rb_call (klass=1076005056, recv=1075972236,
mid=14393,
argc=0, argv=0x0, scope=0) at eval.c:5258
#23 0x080570dd in rb_eval (self=1075604024, n=0x2) at eval.c:3055
#24 0x08053845 in ruby_exec () at eval.c:1407
#25 0x08053895 in ruby_run () at eval.c:1428
#26 0x08051c41 in main () at main.c:50
#27 0x4008f082 in __libc_start_main () from /lib/i686/libc.so.6

Happy Christmas again to all

Neil
 
T

ts

Y> Currently I suspect this is caused by LinuxThread bug. I tried hard

I'm probably wrong, but I don't think it's related to pthread.

The example given can crash with svg and Tk/Tcl is not compiled with
pthread

svg% ldd /usr/lib/libtk.so
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x400c3000)
libdl.so.2 => /lib/libdl.so.2 (0x401a2000)
libm.so.6 => /lib/i686/libm.so.6 (0x401a5000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
libtcl.so.0 => /usr/lib/libtcl.so.0 (0x401c7000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
svg%

svg% ldd /usr/lib/libtcl.so
libdl.so.2 => /lib/libdl.so.2 (0x40095000)
libm.so.6 => /lib/i686/libm.so.6 (0x40099000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
svg%

Y> to solve Nathaniel Talbott's problem, which must be caused by the
Y> same reason, but I couldn't make complete success.

Well, the latest patch at least make it work on Solaris-32 (previously it
blocked very quickly)

nasun% ps ax | grep ruby
17326 ? O 1501:43 ruby s.rb
22284 ? O 246:26 ruby c.rb
22287 ? S 126:48 ruby c.rb
22327 pts/20 S 0:00 grep ruby
nasun%

nasun% pstack 17326
17326: ruby s.rb
----------------- lwp# 1 / thread# 1 --------------------
ff29f6e0 __setcontext (ffbd70f0, ffbd7948, 4, 28dda0, ffbd7b30, ffbd7b60) + 10
0001f0e8 rb_eval (292918, cc800, ffffffff, 3, ca000, d4780) + 108c
000247e4 rb_call0 (1b5c28, 292918, 3f69, ffbd7914, 0, ffbd7c6c) + 474
[...]
0001fa50 rb_eval (106358, cc800, be064, 0, ca000, ca000) + 19f4
0001bae8 ruby_exec (0, ffbefa84, 0, be034, be064, 0) + a0
0001bb40 ruby_run (2, ffbefa84, 0, 0, 0, 0) + 20
00019b48 main (2, ffbefa84, ffbefa90, ccbfc, 0, 0) + 18
000199c8 _start (0, 0, 0, 0, 0, 0) + 5c
----------------- lwp# 2 / thread# 2 --------------------
ff29edc0 signotifywait ()
ff18e950 _dynamiclwps (ff1ac000, 0, 0, 0, 0, 0) + 1c
ff191c2c thr_yield (0, 0, 0, 0, 0, 0) + 8c
----------------- lwp# 3 --------------------------------
ff29c964 door (0, 0, 0, 0, ff175d38, 4)
ff1967c8 _sc_door_func (0, 0, 0, 0, 0, 0) + 54
----------------- lwp# 4 / thread# 4 --------------------
ff29bde0 nanosleep (fee0bd20, fee0bd18)
ff19a440 __nanosleep (0, ff0a3d38, 1, ff1b8d04, 0, 2) + 34
ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
-------------------------- thread# 3 --------------------
ff18d9b8 _reap_wait (ff1b0980, 1e924, 0, ff1ac000, 0, 0) + 38
ff18d710 _reaper (ff1ace00, ff1b2708, ff1b0980, ff1acdd8, 1, fe400000) + 38
ff19b01c _thread_start (0, 0, 0, 0, 0, 0) + 40
nasun%



Guy Decoux
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: TkText freezes"

| I'm probably wrong, but I don't think it's related to pthread.
|
| The example given can crash with svg and Tk/Tcl is not compiled with
| pthread

We have two problems, one that crash, and the other that block. The
former is not related at all with pthread. It's a bug in Ruby.
I think it's fixed by the following patch. The bug I'm suspecting to
be LinuxThread bug is the latter.

matz.
diff -p -u -1 -r1.182 string.c
--- string.c 30 Nov 2003 00:35:28 -0000 1.182
+++ string.c 25 Dec 2003 08:24:39 -0000
@@ -1277,4 +1581,4 @@ rb_str_aref_m(argc, argv, str)

-void
-rb_str_update(str, beg, len, val)
+static void
+rb_str_splice(str, beg, len, val)
VALUE str;
@@ -1322,2 +1626,12 @@ rb_str_update(str, beg, len, val)

+void
+rb_str_update(str, beg, len, val)
+ VALUE str;
+ long beg, len;
+ VALUE val;
+{
+ rb_str_modify(str);
+ return rb_str_splice(str, beg, len, val);
+}
+
static void
@@ -1353,3 +1667,3 @@ rb_str_subpat_set(str, re, nth, val)
rb_str_modify(str);
- rb_str_update(str, start, len, val);
+ rb_str_splice(str, start, len, val);
}
@@ -1384,3 +1698,3 @@ rb_str_aset(str, indx, val)
else {
- rb_str_update(str, idx, 1, val);
+ rb_str_splice(str, idx, 1, val);
}
@@ -1397,3 +1711,3 @@ rb_str_aset(str, indx, val)
}
- rb_str_update(str, beg, RSTRING(indx)->len, val);
+ rb_str_splice(str, beg, RSTRING(indx)->len, val);
return val;
@@ -1405,3 +1719,3 @@ rb_str_aset(str, indx, val)
if (rb_range_beg_len(indx, &beg, &len, RSTRING(str)->len, 2)) {
- rb_str_update(str, beg, len, val);
+ rb_str_splice(str, beg, len, val);
return val;
@@ -1426,3 +1765,3 @@ rb_str_aset_m(argc, argv, str)
else {
- rb_str_update(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
+ rb_str_splice(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
}
@@ -1449,3 +1805,3 @@ rb_str_insert(str, idx, str2)
}
- rb_str_update(str, pos, 0, str2);
+ rb_str_splice(str, pos, 0, str2);
return str;
 
T

ts

Y> We have two problems, one that crash, and the other that block. The
Y> former is not related at all with pthread. It's a bug in Ruby.
Y> I think it's fixed by the following patch. The bug I'm suspecting to
Y> be LinuxThread bug is the latter.

Well, the backtrace when it block (I send it ^C when it don't display
keys)

Program received signal SIGINT, Interrupt.
0x42075047 in malloc_consolidate () from /lib/i686/libc.so.6
(gdb) bt
#0 0x42075047 in malloc_consolidate () from /lib/i686/libc.so.6
#1 0x420746b7 in _int_malloc () from /lib/i686/libc.so.6
#2 0x42073d81 in malloc () from /lib/i686/libc.so.6
#3 0x4027f3df in TclpAlloc () from /usr/lib/libtcl.so.0
#4 0x40283ff6 in Tcl_Alloc () from /usr/lib/libtcl.so.0
#5 0x402b840e in TclExpandTokenArray () from /usr/lib/libtcl.so.0
#6 0x402b8399 in ParseTokens () from /usr/lib/libtcl.so.0
#7 0x402b7e7e in Tcl_ParseCommand () from /usr/lib/libtcl.so.0
#8 0x402b8d56 in Tcl_EvalEx () from /usr/lib/libtcl.so.0
#9 0x402b9185 in Tcl_Eval () from /usr/lib/libtcl.so.0
#10 0x40282813 in Tcl_GlobalEval () from /usr/lib/libtcl.so.0
#11 0x401cdb78 in Tk_BindEvent () from /usr/lib/libtk.so.0
#12 0x401d2525 in TkBindEventProc () from /usr/lib/libtk.so.0
#13 0x401d7d02 in Tk_HandleEvent () from /usr/lib/libtk.so.0
#14 0x401d82c8 in WindowEventProc () from /usr/lib/libtk.so.0
#15 0x402b6355 in Tcl_ServiceEvent () from /usr/lib/libtcl.so.0
#16 0x402b6583 in Tcl_DoOneEvent () from /usr/lib/libtcl.so.0
#17 0x400169f0 in lib_eventloop_core (check_root=1, check_var=0x0)
at tcltklib.c:426
#18 0x40016cf1 in lib_eventloop_main (check_rootwidget=2) at tcltklib.c:520
#19 0x0805a60d in rb_ensure (b_proc=0x40016cc4 <lib_eventloop_main>, data1=2,
e_proc=0x40016d04 <lib_eventloop_ensure>, data2=0) at eval.c:4717
#20 0x40016e79 in lib_eventloop_launcher (check_rootwidget=2) at tcltklib.c:555
#21 0x40016edc in lib_mainloop (argc=1, argv=0xbfffec20, self=1075273536)
at tcltklib.c:576
#22 0x080653f7 in call_cfunc (func=0x40016e9c <lib_mainloop>, recv=1075273536,
len=128, argc=1, argv=0x826ca70) at eval.c:4929
#23 0x0805af55 in rb_call0 (klass=1075273296, recv=1075273536, id=10353, oid=2,
argc=1, argv=0xbfffec20, body=0x40175e3c, nosuper=0) at eval.c:5066
#24 0x0805b73d in rb_call (klass=1075273296, recv=1075273536, mid=10353, argc=1,
argv=0xbfffec20, scope=0) at eval.c:5287
#25 0x08056e81 in rb_eval (self=1075264456, n=0x2) at eval.c:3078
#26 0x0805b23e in rb_call0 (klass=1075270816, recv=1075264456, id=10353, oid=2,
argc=0, argv=0x0, body=0x4007f670, nosuper=0) at eval.c:5194
#27 0x0805b73d in rb_call (klass=1075270816, recv=1075264456, mid=10353, argc=0,
argv=0x0, scope=0) at eval.c:5287
#28 0x08056e81 in rb_eval (self=1074436664, n=0x2) at eval.c:3078
#29 0x0805385c in ruby_exec () at eval.c:1436
#30 0x0805389d in ruby_run () at eval.c:1457
#31 0x08051d79 in main () at main.c:50
#32 0x420158f7 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)



Guy Decoux
 
T

ts

Y> diff -p -u -1 -r1.182 string.c

I don't know if it's related (I've applied the patch)

svg% ruby runner.rb
Loaded suite .
Started
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................EE..EEEF........EE...................................................................................................................................................................................................................
Finished in 63.778409 seconds.

1) Error:
test_bol?(TestStringScanner):
NoMethodError: undefined method `bol?' for #<StringScanner_C 0/20 @ "a
bbb...">
./strscan/test_stringscanner.rb:95:in `test_bol?'

2) Error:
test_concat(TestStringScanner):
NoMethodError: undefined method `concat' for #<StringScanner_C fin>
./strscan/test_stringscanner.rb:147:in `test_concat'

3) Error:
test_eos?(TestStringScanner):
TypeError: can't modify frozen string
./strscan/test_stringscanner.rb:89:in `replace'
./strscan/test_stringscanner.rb:89:in `test_eos?'

4) Error:
test_get_byte(TestStringScanner):
TypeError: can't modify frozen string
./strscan/test_stringscanner.rb:282:in `replace'
./strscan/test_stringscanner.rb:282:in `test_get_byte'

5) Error:
test_getch(TestStringScanner):
TypeError: can't modify frozen string
./strscan/test_stringscanner.rb:251:in `replace'
./strscan/test_stringscanner.rb:251:in `test_getch'

6) Failure:
test_inspect(TestStringScanner) [./strscan/test_stringscanner.rb:70]:
<"#<StringScanner 0/1 @ \"\\n\">"> expected but was
<"#<StringScanner_C 0/1 @ \"\n\">">.

7) Error:
test_scan(TestStringScanner):
TypeError: can't modify frozen string
./strscan/test_stringscanner.rb:204:in `replace'
./strscan/test_stringscanner.rb:204:in `test_scan'

8) Error:
test_skip(TestStringScanner):
TypeError: can't modify frozen string
./strscan/test_stringscanner.rb:222:in `replace'
./strscan/test_stringscanner.rb:222:in `test_skip'

725 tests, 7356 assertions, 1 failures, 7 errors
svg%

svg% ruby -v
ruby 1.8.1 (2003-12-25) [i686-linux]
svg%


Guy Decoux
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: TkText freezes"

|Y> We have two problems, one that crash, and the other that block. The
|Y> former is not related at all with pthread. It's a bug in Ruby.
|Y> I think it's fixed by the following patch. The bug I'm suspecting to
|Y> be LinuxThread bug is the latter.
|
| Well, the backtrace when it block (I send it ^C when it don't display
| keys)

The backtrace tells me little. The patched Ruby and tcltklib.so
linked against Tcl/Tk 8.3 (which is not compiled with -lpthread) works
fine for me. I need additional information to reproduce your blocking
problem.

matz.
 
T

ts

Y> The backtrace tells me little. The patched Ruby and tcltklib.so
Y> linked against Tcl/Tk 8.3 (which is not compiled with -lpthread) works
Y> fine for me. I need additional information to reproduce your blocking
Y> problem.

Well, the problem is that it was 1.8.1-preview4 : it was really easy to
make it crash, a little more difficult to make it block

With 1.8.1 and the patch [ruby-talk:88830] svg don't want to crash or
block :)


Guy Decoux
 
T

ts

t> I don't know if it's related (I've applied the patch)

OK, I've found. There were an old strscan in site_ruby


Guy Decoux
 
T

ts

n> tcl/tk 8.4.2.-1mdk

You are lucky :) your tcl/tk don't use pthread, this can be seen in
[ruby-talk:88794] and [ruby-talk:88808]


Guy Decoux
 
Q

quillion

ts said:
n> tcl/tk 8.4.2.-1mdk

You are lucky :) your tcl/tk don't use pthread, this can be seen in
[ruby-talk:88794] and [ruby-talk:88808]


Guy Decoux
I'm happy and lucky it is an obscure personal program only of interest
to myself... but Ruby lets it happen again

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,364
Latest member
Stevanida

Latest Threads

Top