segfault with tk.rb

Discussion in 'Ruby' started by Wybo Dekker, Mar 28, 2006.

  1. Wybo Dekker

    Wybo Dekker Guest

    This works OK:

    #!/usr/bin/ruby

    require 'tk'
    class TkVariable
    def to_m
    "%.2f" % [self.to_i.abs/100.0]
    end
    end
    puts TkVariable.new(12345).to_m

    -> 123.45

    But when I add the -w option to the first line, I get:

    /usr/local/lib/ruby/1.8/tk.rb:2313: warning: redefine encoding=
    /usr/local/lib/ruby/1.8/tk.rb:2316: warning: redefine encoding
    123.45
    Segmentation fault

    and this takes 45 seconds.
    What's wrong?

    --
    Wybo
     
    Wybo Dekker, Mar 28, 2006
    #1
    1. Advertising

  2. From: Wybo Dekker <>
    Subject: segfault with tk.rb
    Date: Wed, 29 Mar 2006 07:23:55 +0900
    Message-ID: <>
    > But when I add the -w option to the first line, I get:
    >
    > /usr/local/lib/ruby/1.8/tk.rb:2313: warning: redefine encoding=
    > /usr/local/lib/ruby/1.8/tk.rb:2316: warning: redefine encoding
    > 123.45
    > Segmentation fault
    >
    > and this takes 45 seconds.
    > What's wrong?


    I cannot cause SEGV on my Linux box.
    Probably, we need more information to solve your trouble.
    --
    Hidetoshi NAGAI ()
     
    Hidetoshi NAGAI, Mar 29, 2006
    #2
    1. Advertising

  3. Wybo Dekker

    Wybo Dekker Guest

    n Wed, 29 Mar 2006, Hidetoshi NAGAI wrote:

    > I cannot cause SEGV on my Linux box.
    > Probably, we need more information to solve your trouble.


    what would you suggest me to do?

    I tried the profiler:
    #!/usr/bin/ruby -w
    require 'profiler'

    require 'tk'
    class TkVariable
    def to_m
    "%.2f" % [self.to_i.abs/100.0]
    end
    end

    Profiler__::start_profile
    begin
    puts TkVariable.new(12345).to_m
    rescue
    Profiler__::stop_profile
    Profiler__::print_profile($stdout)
    end

    but then the problem is gone.

    I also tried -rdebug, but then I first get, as I always do when using
    tk.rb, a Runtime Error: can't unset "v00000": no such variable, and then
    when I continue, the problem is gone again:

    $ ruby -rdebug t
    Debug.rb
    Emacs support available.

    t:3:require 'tk'
    (rdb:1) c
    /usr/local/lib/ruby/1.8/tk.rb:2313: warning: redefine encoding=
    /usr/local/lib/ruby/1.8/tk.rb:2316: warning: redefine encoding
    /usr/local/lib/ruby/1.8/tk/variable.rb:290: `can't unset "v00000": no
    such variable' (RuntimeError)
    from /usr/local/lib/ruby/1.8/tk/variable.rb:290:in `initialize'
    from t:11
    /usr/local/lib/ruby/1.8/tk/variable.rb:290:
    INTERP._unset_global_var(@id)
    (rdb:1)
    c
    123.45


    --
    Wybo
     
    Wybo Dekker, Mar 29, 2006
    #3
  4. From: Wybo Dekker <>
    Subject: Re: segfault with tk.rb
    Date: Wed, 29 Mar 2006 17:43:43 +0900
    Message-ID: <>
    > what would you suggest me to do?


    Oh, I'm sorry.
    SEGV trouble on Ruby/Tk depends on tcltklib.so.
    # Of course, if the trouble realy depends on Ruby/Tk. ;-)
    To check the reason, information of your environment
    (OS, nativethread suuport, library verion, and so on) are required.

    If you can, please report the followings.

    # If you can also, please try the latest tcltklib.

    * ruby version
    * configure options
    * result of 'ruby -r tk -e 'p Tk::TK_PATCHLEVEL; p Tk::pLATFORM'
    * [depends on your OS] result of ldd your 'ruby' and 'tcltklib.so'
    e.g. $ ldd /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so
    linux-gate.so.1 => (0xffffe000)
    libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0xb7e3d000)
    libdl.so.2 => /lib/libdl.so.2 (0xb7e2c000)
    libpthread.so.0 => /lib/i686/libpthread.so.0 (0xb7ddb000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7dae000)
    libm.so.6 => /lib/i686/libm.so.6 (0xb7d8b000)
    libc.so.6 => /lib/i686/libc.so.6 (0xb7c51000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
    * information which you think useful to solve the trouble :)

    Anyway, the follwoing wraning and error are expecetd.
    Those have no problem, but the exception may cause SEGV.
    However, I think such troubles on exception are fixed on ruby 1.8.3
    or later. If no case of troubles is escaped notice.

    From: Wybo Dekker <>
    Subject: Re: segfault with tk.rb
    Date: Wed, 29 Mar 2006 17:43:43 +0900
    Message-ID: <>
    > $ ruby -rdebug t
    > Debug.rb
    > Emacs support available.
    >
    > t:3:require 'tk'
    > (rdb:1) c
    > /usr/local/lib/ruby/1.8/tk.rb:2313: warning: redefine encoding=
    > /usr/local/lib/ruby/1.8/tk.rb:2316: warning: redefine encoding
    > /usr/local/lib/ruby/1.8/tk/variable.rb:290: `can't unset "v00000": no
    > such variable' (RuntimeError)
    > from /usr/local/lib/ruby/1.8/tk/variable.rb:290:in `initialize'
    > from t:11
    > /usr/local/lib/ruby/1.8/tk/variable.rb:290:
    > INTERP._unset_global_var(@id)

    --
    Hidetoshi NAGAI ()
     
    Hidetoshi NAGAI, Mar 30, 2006
    #4
  5. Wybo Dekker

    Wybo Dekker Guest

    On Thu, 30 Mar 2006, Hidetoshi NAGAI wrote:

    >> what would you suggest me to do?

    >
    > Oh, I'm sorry.
    > SEGV trouble on Ruby/Tk depends on tcltklib.so.
    > # Of course, if the trouble realy depends on Ruby/Tk. ;-)
    > To check the reason, information of your environment
    > (OS, nativethread suuport, library verion, and so on) are required.
    >
    > If you can, please report the followings.
    >
    > # If you can also, please try the latest tcltklib.


    I suppose it *is* the latest, as it comes with ruby-1.8.4?

    > * ruby version


    ruby 1.8.4 (2005-12-24) [i686-linux]

    > * configure options


    none

    > * result of 'ruby -r tk -e 'p Tk::TK_PATCHLEVEL; p Tk::pLATFORM'


    "8.4.7"
    {"wordSize"=>"4", "user"=>"root", "machine"=>"i686", "platform"=>"unix",
    "osVersion"=>"2.6.8-24.20-default", "os"=>"Linux",
    "byteOrder"=>"littleEndian"}

    > * [depends on your OS] result of ldd your 'ruby' and 'tcltklib.so'


    wybo>ldd /usr/local/bin/ruby
    linux-gate.so.1 => (0xffffe000)
    libdl.so.2 => /lib/libdl.so.2 (0x4002d000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x40032000)
    libm.so.6 => /lib/tls/libm.so.6 (0x40064000)
    libc.so.6 => /lib/tls/libc.so.6 (0x40087000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    wybo>ldd /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so
    linux-gate.so.1 => (0xffffe000)
    libtk8.4.so => /usr/lib/libtk8.4.so (0x40029000)
    libtcl8.4.so => /usr/lib/libtcl8.4.so (0x40104000)
    libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x401ac000)
    libdl.so.2 => /lib/libdl.so.2 (0x402a8000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x402ac000)
    libm.so.6 => /lib/tls/libm.so.6 (0x402de000)
    libc.so.6 => /lib/tls/libc.so.6 (0x40301000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

    OS: SuSE-9.2 kept up to date with its online update tool.

    test prog:
    #!/usr/local/bin/ruby -w
    require 'tk'
    class TkVariable
    def to_m
    "%.2f" % [self.to_i.abs/100.0]
    end
    end
    puts TkVariable.new(12345).to_m

    Hope that helps...

    --
    Wybo
     
    Wybo Dekker, Mar 31, 2006
    #5
  6. Thank you for your report.
    I think that depends on the finalize operation of a Tk interpreter
    when Ruby is exiting.
    But now, I have no time to fix the problem.
    If you can, please comment out all part of ip_finalize(ip) in
    tcltklib.c and try to use it.
    Probably, it causes some problems when the running Ruby releases
    Tk IP objects.
    However, on your case, you may be able to avoid the SEGV trouble.
    --
    Hidetoshi NAGAI ()
     
    Hidetoshi NAGAI, Apr 1, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vedran Vyroubal

    STL string segfault

    Vedran Vyroubal, Mar 3, 2004, in forum: C++
    Replies:
    5
    Views:
    1,381
    Vedran Vyroubal
    Mar 4, 2004
  2. Arthur J. O'Dwyer

    multiset segfault

    Arthur J. O'Dwyer, Jun 17, 2004, in forum: C++
    Replies:
    10
    Views:
    750
    Dave Townsend
    Jun 18, 2004
  3. Jim Strathmeyer

    istream segfault

    Jim Strathmeyer, Jul 22, 2004, in forum: C++
    Replies:
    4
    Views:
    452
    Mike Wahler
    Jul 23, 2004
  4. William Payne
    Replies:
    4
    Views:
    520
    Karthiik Kumar
    Aug 28, 2004
  5. Andrey Vul
    Replies:
    8
    Views:
    706
    Richard Bos
    Jul 30, 2010
Loading...

Share This Page