Bus Error with tk app

From: “Mike Wilson” wmwilson01@hotmail.com
Reply-To: ruby-talk@ruby-lang.org
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Subject: Bus Error with tk app
Date: Thu, 4 Mar 2004 01:58:40 +0900

I have a (horribly written) tk app which used to work just fine. I
recently added threading to it, and it now works fine for some period of
time, but then crashses leaving only:

->8–>8–
/usr/local/lib/ruby/1.8/tk.rb:1623: [BUG] Bus Error
ruby 1.8.1 (2003-12-25) [sparc-solaris2.8]

Abort
->8–>8–

The recently modified code is this:

threads =
check_status = proc {
threads.clear
$labels.each_key do |aHost|
threads << Thread.new(aHost) do |host|
if $look[host] == 1
if system(“ping #{host} 4 > /dev/null 2>&1”)
…snip…
else
…snip…
end
end
end
end
updater.configure(‘text’ => "Last update: " +
Time.new.strftime(DATE_FORMAT + “:%S”))
Tk.after(tknm_interval, &check_status)
}
check_status.call
threads.each do |t| t.join end
Tk.mainloop()

Am I doing something wrong here?

Is this a bug?

···

Frustrated with dial-up? Lightning-fast Internet access for as low as
$29.95/month. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/

Hi,

At Sat, 6 Mar 2004 04:36:44 +0900,
Mike Wilson wrote in [ruby-talk:94386]:

/usr/local/lib/ruby/1.8/tk.rb:1623: [BUG] Bus Error
ruby 1.8.1 (2003-12-25) [sparc-solaris2.8]

Is this a bug?

Try CVS HEAD version. There were some significant fixes after
1.8.1 release.

···


Nobu Nakada

Hi,

···

From: “Mike Wilson” wmwilson01@hotmail.com
Subject: Re: Bus Error with tk app
Date: Sat, 6 Mar 2004 04:36:44 +0900
Message-ID: BAY15-F55g91Blas0pg00007d22@hotmail.com

Is this a bug?

Probably. But I cannot do enough test your script because I don’t
have a solaris environment and the shown code is only a part. I
couldn’t reproduce your problem on my Linux environment (your
snipped parts are replaced to print messages).

Which version of Tcl/Tk do you use?
Is your ruby (and Tcl/Tk) compiled with thread support?
Do you get same result when use TkTimer class?
For example,

threads =
check_status = proc {
threads.clear
$labels.each_key do |aHost|
threads << Thread.new(aHost) do |host|
if $look[host] == 1
if system(“ping #{host} 4 > /dev/null 2>&1”)
…snip…
else
…snip…
end
end
end
end
updater.configure(‘text’ => "Last update: " + Time.new.strftime(DATE_FORMAT + “:%S”))
# Tk.after(tknm_interval, &check_status) → remove this line
}

check_status.call

threads.each do |t| t.join end

TkTimer.new(tknm_interval, -1, check_status).start
Tk.mainloop()

Please read tktimer2.rb or tktimer3.rb on ext/tk/sample directory of
Ruby soruce archive.

I’m trying to fix some known problems at the same time to fixing the
problem of exporting/inporting binary (with null byte) string to the
Tk interpreter. I think the trouble depends on thread switching when
doing operations having interaction between ruby and tk interpreter.
It may be a sensitive issue (especially involving POSIX threads).

I’m busy now and don’t have enough time to work on the problems.
So, it will be difficult to fix the problems over the next few weeks
(Maybe I cannot fix completely without many helps). As if I cannot
fix completely, I endeavor to improve Ruby/Tk and to release the trial
version of patch in a few weeks.

                              Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)