Bugs: Browse | Submit New | Admin

[#27245] Crash occurring with GC and simple TaskBarIcon

Date:
2009-10-06 09:07
Priority:
4
Submitted By:
Muriel Salvan (muriel)
Assigned To:
Alex Fenton (brokentoy)
Category:
Incorrect behavior
State:
Open
Summary:
Crash occurring with GC and simple TaskBarIcon

Detailed description
Greetings

SegFaults occur randomly when using a popup menu from a TaskBarIcon.

Problem does not occur when disabling Ruby's GarbageCollector.

Problem occurs very frequently when using gc_stress in the application's initialization.

Problem occurs even on samples/bigdemo.

Here is the test procedure:
1- Add a call to gc_stress in the on_init method.
2- Invoke repeatedly a menu item from the TaskBarIcon menu (for example "Change the TB icon" from bigdemo.rb)
several times (normally the crash occurs before 10 times).

I have attached a simple example creating a basic Frame with a TaskBarIcon, and the problem occurs as described above.

Please tell me if I can help to solve this issue, as it makes any real application using a tray icon unusable (disabling
GC is not option to me).

Best regards,

Muriel

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-01-21 22:27
Sender: Muriel Salvan

Hi Alex

Do you have any news on this one ?

Thanks for your effort
Muriel
Date: 2009-11-04 09:22
Sender: Alex Fenton

OK, thanks Muriel, I will take another look at it. The Menus
should be recursively protected as they would be in a menubar,
but clearly this isn't working.

alex
Date: 2009-11-03 19:30
Sender: Muriel Salvan

Changed resolution
Date: 2009-11-03 19:28
Sender: Muriel Salvan

Hi Alex

I am sorry but I think I have to reopen it, because the
workaround you mention does not work for complex menus.

Dealing with sub-menus and menu items belonging to sub-menus
still produces core dumps.

I attach another example that creates a hierarchical menu
structure (based on constants defining the depth of the tree
and the number of items and sub-menus per menu).

I applied the workaround you found for every sub-menu
created (and even menu items with no luck).

To get the error, it is needed to have at least a depth of 2
sub-menus, with another brother sub-menu and a menu item
belonging to the most indepth sub-menu. Like this (SM:
SubMenu, MI: MenuItem):
  # +-SM0
  # | +-SM0
  # | | +-MI0
  # | +-SM1
  # |   +-MI0
  # +-SM1
  # | +-SM0
  # | | +-MI0
  # | +-SM1
  # |   +-MI0
  # +-MI0

With this configuration, invoking repeatedly the tray menu
(without having to select any menu item) produces core dumps.

You can play with the constants inside the example, but be
careful at the depth: it will create menu items exponentially.

My config:
* wxRuby 2.0.1
* Windows XP Pro
* Ruby 1.8.5

If I can help you more in resolving this issue, please tell
me, as these core dumps are quite cumbersome.

Thanks for your help and best regards
Muriel
Date: 2009-11-03 14:22
Sender: Muriel Salvan

And forgot to mention one thing:

This workaround has to be made also for any sub-menu that is
created and returned under create_popup_menu.

Best regards
Muriel
Date: 2009-11-03 10:50
Sender: Muriel Salvan

Hi Alex

Thanks a lot for the workaround, it works perfectly for this
issue.

Great work !

Best regards,
Muriel
Date: 2009-10-31 12:37
Sender: Alex Fenton

Fixed by SVN:2107.

As a workaround that doesn't involve switching off GC, you can
use something like the following:

def create_popup_menu
  @menu = Wx::Menu.new()
  # ... add items
  return @menu
end

i.e. make the menu an instance variable of the TaskBarIcon, rather
than a local variable.

I'd be grateful if you could let me know if this doesn't resolve
this issue, as the fix I've applied uses a similar mechanism.

Thanks again for the report.
Date: 2009-10-28 20:02
Sender: Alex Fenton

Hi Muriel

Thank you for the report and the sample. I can reproduce the
error (on OS X) and I believe it's something to do with memory
management for the popup menu. I will investigate further and
fix for the next release, which I plan to be soon.

Alex
Date: 2009-10-06 09:10
Sender: Muriel Salvan

Sorry, forgot to specify my config:

wxRuby 2.0.1 on Windows XP.

Best regards,
Muriel

Attached Files:

Name Description Download
TrayCrash.rb Simple example of TaskBar icon menu crashing Download
TrayCrash2.rb Hierarchical tray menu Download

Changes:

Field Old Value Date By
File Added4791: TrayCrash2.rb2009-11-03 19:28muriel
status_idClosed2009-11-03 19:28muriel
close_date2009-11-03 14:222009-11-03 14:22muriel
close_date2009-11-03 10:502009-11-03 10:50muriel
close_date2009-10-31 12:372009-10-31 12:37brokentoy
resolution_idNone2009-10-31 12:37brokentoy
status_idOpen2009-10-31 12:37brokentoy
assigned_tonone2009-10-28 20:02brokentoy
priority32009-10-28 20:02brokentoy
File Added4757: TrayCrash.rb2009-10-06 09:07muriel