Bug #8000

"require 'tk'" segfaults on 64-bit linux with Tk 8.6

Added by Ed McCardell about 1 year ago. Updated 10 months ago.

[ruby-core:53097]
Status:Open
Priority:Normal
Assignee:Hidetoshi Nagai
Category:-
Target version:-
ruby -v:ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux] Backport:

Description

Using ruby 1.9.3p392 and Tk 8.6.0 on 64-bit Arch Linux, attempting to "require 'tk'" causes a segfault.

To reproduce:
ruby -e "require 'tk'"

The crash log is in the attached file.

Notes:
- I've heard from a Gentoo user who is having the same problem.
- On 32-bit Arch Linux, there is no problem.

crash.log (16.2 KB) Ed McCardell, 03/02/2013 02:43 PM

bt.txt Magnifier (1.82 KB) Alexander Ponimaskin, 03/06/2013 04:25 AM

bt-debug.txt Magnifier (4.47 KB) Ed McCardell, 03/08/2013 05:55 PM

crash-2.txt Magnifier (4.49 KB) Ed McCardell, 03/19/2013 03:04 PM

History

#1 Updated by Jon Forums about 1 year ago

Did you build tcltk, or install binaries via pacman? This seems wacky if you used pacman, but does file prove /usr/lib/libtcl8.6.so and /usr/lib/libtk8.6.so are 64bit?

Since it crashes so easily, fire up gdb via something like

gdb --args ruby -e "require 'tk'"

run it, and attach the backtrace.

#2 Updated by Alexander Ponimaskin about 1 year ago

All packages are installed via packman

/usr/lib/libtcl8.6.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x31a66c5d6eacb77f2a9a220bff2e78a88821167e, not stripped

/usr/lib/libtk8.6.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0xdfa2df7ef1e30e3fbe510a294f8fe781415ee964, not stripped

#3 Updated by Jon Forums about 1 year ago

One of the committers please assign this to Hidetoshi NAGAI.

Too bad tcltklib.so is stripped and the bt is weak. I bet no one on ruby-core has an Arch x64 system to try to repro/debug the issue, so we need to get better debug info. (Or reproduce it on a Ubuntu x64 system)

Are you able to build ruby? If you did a pacman install of Arch's ruby 1.9.3_p392 package, you should be able to build from source, and tweak configure's optflags and debugflags to build tcltklib.so with debug info. The default install is to /usr/local so your Arch pkg won't get clobbered if you don't use --prefix.

My Arch x64 system is cmd line only. When I tried to cheat a repro/debug by installing tcl/tk add it's 15 friends, ruby -e "require 'tk'" rightfully failed due to no display. I don't know whether it failed before or after your segv. When I get time, I'll standup a new ArchBang install and try again. It looks as if tcltklib.so could be passing a bad value into the tcl library. Hard to tell from the bt.

Before you try building from source have you pinged the Arch Forum? I'd skimmed posts on Newbie Corner and Installation and didn't see mention of this issue. Have you contacted Arch's ruby packager (Thomas Dziedzic) to confirm whether he's seeing the issue? Given it fails so quickly, I was surprised not to find it in the forums.

Then again, Nagai-san may soon see this issue and swoop in with the solution ;)

#4 Updated by Hidetoshi Nagai about 1 year ago

First of all, current Ruby/Tk cannot support Tcl/Tk8.6. Please see .
But, I don't know whether this trouble belongs to the "tailcall" problem or not.
Does the same trouble occur with Tcl/Tk8.5 ? If so, tcltklib may not follow the changes on Ruby's core.

Of course, I must fix this bug and should support Tcl/Tk8.6.
However, I don't have enough time to work on it,
and unfortunately I have no idea to avoid the "tailcall" problem now.

#5 Updated by Ed McCardell about 1 year ago

Jon: I've just posted to Newbie Corner on the Arch forums. The only other place on the internet that I've seen this is in the forums for the Coursera Programming languages class I'm taking, where several other users have reported it. I'll build ruby/tcl/tk from source tonight with debug info and get a better trace.

Nagai-san: Using the latest version of Arch linux ruby that was built against Tcl/Tk 8.5 works fine (that's ruby 1.9.3 p127). I don't know about the tailcall problem, but on 32-bit Arch linux with Tcl/Tk 8.6, the ruby/tk scripts I run are working without segfault.

#6 Updated by Ed McCardell about 1 year ago

Now that I've tried a few more ruby/tk scripts, I see that only a limited subset of tk works on 32-bit under Tk8.6. But in case it's still useful, I've attached a backtrace from gdb using ruby1.9.3p392/tcl8.6/tk8.6 with debug info on 64-bit.

#7 Updated by Jon Forums about 1 year ago

First of all, current Ruby/Tk cannot support Tcl/Tk8.6. Please see .
But, I don't know whether this trouble belongs to the "tailcall" problem or not.

Nagai-san: thanks for the info. FYI, while it's not really relevant to Ed's Arch issue, I'm running Tcl/Tk8.6 on Win7 32bit on ruby 1.9.3p393 and ruby 2.0.0p19 built with mingw-w64 4.7.2 and I've not yet seen any problems with test scripts like http://pastie.org/6420781

#8 Updated by Hidetoshi Nagai about 1 year ago

Could you test the following script?


module TkCore; RUNEVENTLOOPONMAINTHREAD = true; end
require 'tk'
Tk.mainloop


If it works, a bug may exist on handling a Thread.

From: "edmccard (Ed McCardell)" edmccard@hotmail.com
Subject: [ruby-trunk - Bug #8000] "require 'tk'" segfaults on 64-bit linux with Tk 8.6
Date: Fri, 8 Mar 2013 17:55:30 +0900
Message-ID: redmine.journal-37386.20130308175529@ruby-lang.org

Issue #8000 has been updated by edmccard (Ed McCardell).

File bt-debug.txt added

Now that I've tried a few more ruby/tk scripts, I see that only a limited subset of tk works on 32-bit under Tk8.6. But in case it's still useful, I've attached a backtrace from gdb using ruby1.9.3p392/tcl8.6/tk8.6 with debug info on 64-bit.

Bug #8000: "require 'tk'" segfaults on 64-bit linux with Tk 8.6
https://bugs.ruby-lang.org/issues/8000#change-37386

Author: edmccard (Ed McCardell)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

Using ruby 1.9.3p392 and Tk 8.6.0 on 64-bit Arch Linux, attempting to "require 'tk'" causes a segfault.

To reproduce:
ruby -e "require 'tk'"

The crash log is in the attached file.

Notes:
- I've heard from a Gentoo user who is having the same problem.
- On 32-bit Arch Linux, there is no problem.

http://bugs.ruby-lang.org/

#9 Updated by Ed McCardell about 1 year ago

That script,

module TkCore; RUNEVENTLOOPONMAINTHREAD = true; end
require 'tk'
Tk.mainloop


gives the result:

called Tcl_FindHashEntry on deleted table
Aborted (core dumped)

The same thing happens if the final line is commented out.

#10 Updated by Hiroshi SHIBATA about 1 year ago

  • Assignee set to Hidetoshi Nagai

#11 Updated by Ed McCardell about 1 year ago

Attached is the gdb backtrace from running nagai's test script.

#12 Updated by Hidetoshi Nagai 10 months ago

Currently, Ruby/Tk cannot support Tcl/Tk8.6. Please use Tcl/Tk8.5.
I want to add Tcl/Tk8.6 to supported version. But it is a future work.

Also available in: Atom PDF