require 'tk' causes segfault later 
Author Message
 require 'tk' causes segfault later

I've got a Ruby app that creates a tree data structure and then
recursively walks that structure to generate some data - that's the short
description (the longer description has to do with generating test
vectors for finite state machines (FSMs)).  It's been working fine.  
Yesterday I decided that I wanted to be able to see what that tree structure
looks like so I decided to use SvgCanvas (see SvgCanvas in the RubyGarden
wiki) which uses dot to generate an svg file and imports it into TkCanvas -
it works pretty nicely, BTW (except for the segfault on large testcases).

After making these additions, it seemed to work fine.  But then I tried a
larger testcase (which used to work) that generates a tree with several
hundred nodes and I found that the script segfaults.  I turned off the
tree drawing feature thinking that that was the problem, but it still
segfaulted which was odd (as far as I knew the script was back to the
state it was in prior to adding the drawing feature).  Then I noticed that
I still had the 'require "tk"' at the top of the script.  After commenting
that out the problem went away.

Does requiring Tk take a lot of memory or something?  Any ideas?

(BTW: TkCanvas is pretty nice as it's quite easy to get postscript from a
canvas)

Phil
--
"Or perhaps the truth is less interesting than the facts?"
Amy Weiss (accusing theregister.co.uk of engaging in 'tabloid journalism')
Senior VP, Communications
Recording Industry Association of America  



Mon, 23 May 2005 03:44:26 GMT  
 require 'tk' causes segfault later

Quote:

> hundred nodes and I found that the script segfaults.  I turned off the
> tree drawing feature thinking that that was the problem, but it still
> segfaulted which was odd (as far as I knew the script was back to the
> state it was in prior to adding the drawing feature).  Then I noticed that
> I still had the 'require "tk"' at the top of the script.  After commenting
> that out the problem went away.

> Does requiring Tk take a lot of memory or something?  Any ideas?

Which version of Ruby are you using and on which platform?

Rob



Mon, 23 May 2005 18:50:55 GMT  
 require 'tk' causes segfault later


Quote:

>> hundred nodes and I found that the script segfaults.  I turned off the
>> tree drawing feature thinking that that was the problem, but it still
>> segfaulted which was odd (as far as I knew the script was back to the
>> state it was in prior to adding the drawing feature).  Then I noticed that
>> I still had the 'require "tk"' at the top of the script.  After commenting
>> that out the problem went away.

>> Does requiring Tk take a lot of memory or something?  Any ideas?

>Which version of Ruby are you using and on which platform?

ruby 1.6.7 (2002-03-01) [i686-linux-gnu]

I also tried with 1.7.3 on linux and it also segfaulted.

It's not a huge problem for me right now as I've changed the code so that
the require is done after the large tree structure is built and that works
fine - it's just that anytime there's a segfault it could be an indicator
that something is rotten somewhere ;-)  in this case I'm not sure if it's
in the tk extension or Ruby itself.

One thing to note: The tree structure is built recursively and in this
particular test case the recursion goes pretty deep - could it be some
kind of stack overflow problem?

Phil
--
"Or perhaps the truth is less interesting than the facts?"
Amy Weiss (accusing theregister.co.uk of engaging in 'tabloid journalism')
Senior VP, Communications
Recording Industry Association of America  



Tue, 24 May 2005 04:17:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Tk bind to 'FocusOut' causes segfault

2. Latest 1.6.7 release works, but latest 1.7.2 doesn't

3. can't package require Tk?!?

4. What causes 'Internal error 5333'?

5. don't understand cause of `sysread': Bad file descriptor (Errno::EBADF)

6. 'proc unknown' causes package error

7. Running 'make test' causes core dump

8. 'after' causes illegal instruction errors

9. Wanted : old computers from late 70's early 80's

10. 'StdCLib required'

11. 'require' search path

12. 'require' error (ver/path)

 

 
Powered by phpBB® Forum Software