Forum: wxRuby MethodMissing calc_min

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-03-30 16:35
(Received via mailing list)
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 Will

/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 `<main>'
rakaur@callandor ~/Dropbox/Sources/work/Palaeoptera $

Line 34 is a show() call for a Wx::Frame.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-03-30 21:18
(Received via mailing list)
Eric Will 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
808859d21eaeec75c485756b6bc7d0b9?d=identicon&s=25 Eric Will (Guest)
on 2009-03-31 00:03
(Received via mailing list)
On Mar 30, 2009, at 3:05 PM, Alex Fenton <alex@pressure.to> 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 Will
This topic is locked and can not be replied to.