Problem with tk

hello,
here is the script:

require 'tk’
t=TkText.new.pack
t.tag_configure(‘test’,‘foreground’=>‘blue’)
t.tag_bind(‘test’,‘Enter’,proc { puts ‘test’})
t.insert(‘end’,‘hello crash’)
Tk.mainloop

and here is the error:

/opt/sfw/lib/ruby/1.6/tk.rb:653:in tk_call': invalid command nametag’
(NameError)
from /opt/sfw/lib/ruby/1.6/tk.rb:371:in _bind_core' from /opt/sfw/lib/ruby/1.6/tk.rb:379:in_bind’
from /opt/sfw/lib/ruby/1.6/tktext.rb:269:in `tag_bind’
from tag.rb:4

am I doing something wrong, or is there a problem with tktext.rb ?

thx,
jf

Hi,

···

From: MENON Jean-Francois jean-francois.menon@meteo.fr
Subject: problem with tk
Date: Wed, 5 Feb 2003 00:34:05 +0900
Message-ID: 3E3FDB13.80E1A070@meteo.fr

am I doing something wrong, or is there a problem with tktext.rb ?

Sorry. It is a shameful bug.

— tktext.rb~ Tue Feb 4 23:35:10 2003
+++ tktext.rb Wed Feb 5 00:59:15 2003
@@ -173,15 +173,15 @@
end

def tag_bind(tag, seq, cmd=Proc.new, args=nil)

  • _bind([‘tag’, ‘bind’, tag], seq, cmd, args)
  • _bind([@path, ‘tag’, ‘bind’, tag], seq, cmd, args)
    end

def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)

  • _bind_append([‘tag’, ‘bind’, tag], seq, cmd, args)
  • _bind_append([@path, ‘tag’, ‘bind’, tag], seq, cmd, args)
    end

def tag_bindinfo(tag, context=nil)

  • _bindinfo([‘tag’, ‘bind’, tag], context)
  • _bindinfo([@path, ‘tag’, ‘bind’, tag], context)
    end

def tag_cget(tag, key)


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

Greetings,

I’m sure that there are many project maintainers and OS X/Ruby users
who will be interested in what I have discovered.

Like many OS X/Ruby users, I too was bitten by the “stack level too
deep” error when running some scripts. Based on my own limited
experience, the bug happened when running Unit::Test and scripts that
use the REXML library.

The fix so far was to add a line to your .profile (or .tcshrc if you’re
using tcsh) that looked like one of the following: (assuming an 8K
stack size)

limit stacksize 8192 # tcsh
ulimit -s 8192 #bash/sh

Currently the stack size in OS X is 512 bytes. As a point of
comparison, Linux enjoys a 32K stack size.

However, this fix did not work in all environments. For example, if
you wrote a cgi script that was deeply recursive (as an example), you
would get the dreaded “stack level too deep” error - because Apache
still thinks the stack size is 512 bytses.

I put the question about how to increase the stack size to the Apple
Discussion forum (http://discussions.info.apple.com/, click "Mac OS X"
under System Software Discussions; click “Unix” (2nd from the bottom);
look for ““Stack Level Too Deep” error and Apache”), and got a very
interesting answer.

/etc/rc.common is one of the first scripts in OS X that gets executed.
It’s a sh script, so if you add:

ulimit -s 8192

to the bottom of it, then restart the machine, then the stack size will
be big enough to run many more ruby scripts. Don’t use the tcsh
equivalent (limit stacksize 8192), because at this point you’re running
an sh script, not a tcsh script.

As a gentle reminder for those people who like to keep their config
files clean: If you make this modification to rc.common, and you
already modified your shell profile with a line like this, you might
want to remove that line from your profile.

see ya,
-rh

Robert Hahn rhahn@quarry.com wrote in message news:77CEA604-3866-11D7-AE20-003065F88A34@quarry.com

Greetings,

I’m sure that there are many project maintainers and OS X/Ruby users
who will be interested in what I have discovered.

Like many OS X/Ruby users, I too was bitten by the “stack level too
deep” error when running some scripts. Based on my own limited
experience, the bug happened when running Unit::Test and scripts that
use the REXML library.

The fix so far was to add a line to your .profile (or .tcshrc if you’re
using tcsh) that looked like one of the following: (assuming an 8K
stack size)

limit stacksize 8192 # tcsh
ulimit -s 8192 #bash/sh

Currently the stack size in OS X is 512 bytes. As a point of
comparison, Linux enjoys a 32K stack size.
The maximum stack size in OS X is in kilobytes, not bytes. So the
default is really 512K. As I understand it, the stack is actually
dynamically allocated by the kernel, so it will start out small and
grow up to the set limit.

Using a max stack size of 1M, I am able to do all my REXML parsing
that failed with a 512K stack limit.

···

However, this fix did not work in all environments. For example, if
you wrote a cgi script that was deeply recursive (as an example), you
would get the dreaded “stack level too deep” error - because Apache
still thinks the stack size is 512 bytses.

I put the question about how to increase the stack size to the Apple
Discussion forum (http://discussions.info.apple.com/, click “Mac OS X”
under System Software Discussions; click “Unix” (2nd from the bottom);
look for ““Stack Level Too Deep” error and Apache”), and got a very
interesting answer.

/etc/rc.common is one of the first scripts in OS X that gets executed.
It’s a sh script, so if you add:

ulimit -s 8192

to the bottom of it, then restart the machine, then the stack size will
be big enough to run many more ruby scripts. Don’t use the tcsh
equivalent (limit stacksize 8192), because at this point you’re running
an sh script, not a tcsh script.

As a gentle reminder for those people who like to keep their config
files clean: If you make this modification to rc.common, and you
already modified your shell profile with a line like this, you might
want to remove that line from your profile.

see ya,
-rh