MethodMissing calc_min

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 methodcalc_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:incalc_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:incalc_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:inprocess_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:inshow’
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:innew’
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:incall’
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:incall’
from bin/Palaeoptera.rb:20:in process_event' from bin/Palaeoptera.rb:20:inprocess_event’
from bin/Palaeoptera.rb:20:in process_event' from bin/Palaeoptera.rb:20:inon_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.

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

On Mar 30, 2009, at 3:05 PM, Alex F. [email protected] 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.