# MethodMissing calc\_min

**URL:** <https://www.ruby-forum.com/t/methodmissing-calc-min/164260>\
**Category:** wxRuby\
**Created:** [March 30, 2009, 4:35pm UTC](https://www.ruby-forum.com/t/methodmissing-calc-min/164260 "2009-03-30T16:35:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [March 30, 2009, 4:35pm UTC](https://www.ruby-forum.com/t/methodmissing-calc-min/164260/1 "2009-03-30T16:35:24Z")

</div>

This is kind of hard to explain, but I’ll do my best.

I have a window that has a complex ListCtrl using LC\_VIRTUAL, and my  
own implementation of ListView. I use this tons of places and it works  
fine, except for here. In Ruby 1.8 there’s no warning, just a segfault  
out of nowhere. In Ruby 1.9, when trying to do set\_size() on the  
Wx::Frame or show(), it crashes every time by raising a NoMethodError  
on “calc\_min” for various objects. The object changes every time, but  
has been String, Array, Hash, and various of my own objects. I don’t  
do anything with calc\_min() in my ListView, and this doesn’t happen  
ANYWHERE else. Sometimes it works fine on 1.8, and sometimes it  
segfaults. I can make the code available on a limited basis (it is  
private, for the US government), preferably only to Alex, if you think  
you can help.

I know that’s not a ton of information, but I’m not sure what else I  
can include. I’ve tried very hard to make sure it’s not something I’m  
doing, and I can’t reproduce it with anything but the exact code I use  
now. In order for you to reproduce it you’d probably need the whole  
program (which is huge, and complicated), but I can provide you with  
traces or anything you need.

Thanks for any help you can provide.

– Eric W.

/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`calc_min': undefined method`calc\_min’ for  
#DateTime:0x00000003046de0 (NoMethodError)  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`calc_min' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in`calc\_min’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`calc_min' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in`calc\_min’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`layout' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in`process\_event’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`process_event' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in`show’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera/ui/equipmentfinder.rb:34:in  
`initialize' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera.rb:173:in`new’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Palaeoptera.rb:173:in  
`block in on_init' from /home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Hymenoptera/ui/main.rb:106:in`call’  
from  
/home/rakaur/Dropbox/Sources/work/Palaeoptera/lib/Hymenoptera/ui/main.rb:106:in  
`block (2 levels) in initialize_events' from bin/Palaeoptera.rb:20:in`call’  
from bin/Palaeoptera.rb:20:in `process_event' from bin/Palaeoptera.rb:20:in`process\_event’  
from bin/Palaeoptera.rb:20:in `process_event' from bin/Palaeoptera.rb:20:in`on\_run’  
from bin/Palaeoptera.rb:20:in `main_loop' from bin/Palaeoptera.rb:20:in`’  
rakaur@callandor ~/Dropbox/Sources/work/Palaeoptera $

Line 34 is a show() call for a Wx::Frame.

---

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [March 30, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/methodmissing-calc-min/164260/2 "2009-03-30T21:18:22Z")

</div>

Eric W. wrote:

> ANYWHERE else. Sometimes it works fine on 1.8, and sometimes it  
> segfaults. I can make the code available on a limited basis (it is  
> private, for the US government), preferably only to Alex, if you think  
> you can help.

From the sound of it it’s some kind of memory / object-tracking bug. I  
haven’t come across one for a while but they are quite hard to diagnose  
and reproduce.

calc\_min is an overridable method of Wx::Sizer; like other similar  
methods, it’s sometimes called by the C++ core. Probably wxRuby is  
trying to call this on an Ruby object it thinks is a Wx::Sizer, but is  
something else.

If you want to contact me off-list I can take a look at your code on a  
confidential basis. I’m a bit short of time but can try to reproduce it,  
although the bugs are often dependent on each platform’s memory  
allocation order. It might be useful to know also:

- if the Frame concerned is explicitly sized, rather than using Sizers  
(as perhaps the other non-problematic ones)
- if the bug only occurs after some Frame has been opened and destroyed

a

---

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [March 31, 2009, 12:03am UTC](https://www.ruby-forum.com/t/methodmissing-calc-min/164260/3 "2009-03-31T00:03:07Z")

</div>

On Mar 30, 2009, at 3:05 PM, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you want to contact me off-list I can take a look at your code on  
> a confidential basis. I’m a bit short of time but can try to  
> reproduce it, although the bugs are often dependent on each  
> platform’s memory allocation order. It might be useful to know also:
> 
> - if the Frame concerned is explicitly sized, rather than using  
> Sizers (as perhaps the other non-problematic ones)
> - if the bug only occurs after some Frame has been opened and  
> destroyed

It happens in OS X, WinXP, and Linux. It crashes while trying to  
show() the Frame the ListView is in. It often tries calc\_min() on  
members of my ListView. All my windows use Sizers.

I’ll get back to you tomorrow. Off work for now. I’m going to do some  
poking in my ListView which I have no problem making available before  
I burden anyone.

–  
Eric W.
