# Timing issue

**URL:** <https://www.ruby-forum.com/t/timing-issue/202917>\
**Category:** wxRuby\
**Created:** [February 8, 2011, 10:38pm UTC](https://www.ruby-forum.com/t/timing-issue/202917 "2011-02-08T22:38:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 8, 2011, 10:38pm UTC](https://www.ruby-forum.com/t/timing-issue/202917/1 "2011-02-08T22:38:17Z")

</div>

I believe I’ve run afoul of a timing issue in wxruby that might explain  
some  
peoples’ segfaults.

I have a radio button page as part of a notebook that selects a file to  
read  
in, which triggers a whole lot of other changes, including a rebuild of  
one  
of the other notebook pages.

If I’m slow and deliberate (like 2+ seconds between clicks) it all  
works  
fine. However, if I click faster, I WILL get a segfault. Since my  
printed  
puts statements are all executing, my processing is being completed.  
Unfortunately, it appears that there is still background processing  
occurring at either the wxruby or wxW level that is not protected  
against  
such occurrences.

How can I test for this and either defer the click processing or veto  
it?

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [February 9, 2011, 9:45am UTC](https://www.ruby-forum.com/t/timing-issue/202917/2 "2011-02-09T09:45:12Z")

</div>

On 08.02.2011 22:10, Don W. wrote:

> How can I test for this and either defer the click processing or veto it?

I think the main problem is that the integration with the garbage  
collector is buggy and if enough stuff happens between when your object  
becomes garbage and when it is actually collected some data structures  
become corrupted. For example, I can completely avoid the segfaults in  
[http://rubyforge.org/tracker/index.php?func=detail&aid=28871&group\_id=35&atid=218](http://rubyforge.org/tracker/index.php?func=detail&aid=28871&group_id=35&atid=218)  
by immediately calling GC.start() after destroying the temporary  
windows, and the probability of a segfault goes down if I decrease the  
timer interval so it runs more often so more stuff gets allocated and  
the collector runs more often.

- Florian.

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [February 9, 2011, 6:51pm UTC](https://www.ruby-forum.com/t/timing-issue/202917/3 "2011-02-09T18:51:03Z")

</div>

On Wed, Feb 9, 2011 at 12:22 AM, Florian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> windows, and the probability of a segfault goes down if I decrease the  
> timer interval so it runs more often so more stuff gets allocated and  
> the collector runs more often.
> 
> That does make a scary kind of sense. I reconstitute an entire tab book  
> page with hundreds of elements on it, and of course the old elements  
> become  
> garbage.

if this is known-buggy, and nobody knows a better way to identify  
completion  
of the cleanup, I’ll have to rig another timer to defer the new  
operations  
for a few seconds.

I’ll add the explicit call like you suggest, too, Florian. Thanks for  
the  
understanding and tips.

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [February 9, 2011, 7:34pm UTC](https://www.ruby-forum.com/t/timing-issue/202917/4 "2011-02-09T19:34:20Z")

</div>

On Wed, Feb 9, 2011 at 9:24 AM, Don W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Wed, Feb 9, 2011 at 12:22 AM, Florian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > On 08.02.2011 22:10, Don W. wrote:

[snip]

> completion of the cleanup, I’ll have to rig another timer to defer the new  
> operations for a few seconds.
> 
> I’ll add the explicit call like you suggest, too, Florian. Thanks for the  
> understanding and tips.

Florian, the explixcit GC call was indeed all I needed. Many thanks! 😃
