#11 new
lyle (at lylejohnson)

Segmentation Fault involving FXMessageBox and sockets

Reported by lyle (at lylejohnson) | November 11th, 2009 @ 06:37 PM

Original submitter wrote:

"I’ve been experiencing a strange crash that involves using FXMessageBox, and having another thread that is interacting with a socket. Attached is the code that very quickly crashes for me after pressing the “Press Me” button. Note
that the program will run forever until the MessageBox is shown. (I believe the same issue also exists with the File
choosers.)

My system specs:
Windows XP SP2
Ruby 1.8.6 p0
FXRuby 1.6.17

Can anyone else recreate this on your system?"

Comments and changes to this ticket

  • lyle (at lylejohnson)

    lyle (at lylejohnson) November 11th, 2009 @ 06:40 PM

    Ryan Melton added the following:

    Here's the fix, the issue turned out to be very complicated related to how ruby handles the stack frames of its threads. In summary, you can't access stack variables between threads. FXMessageBox::warning creates the FXMessageBox on the stack. If the Garbage Collector running in another threads context tries to access the FXMessageBox, it blows up because the stack values are no longer in context. Below is the fix.

    Add this method to FXRbApp.cpp:

    FXWindow *FXApp::getFocusWindow() const {
      FXWindow *result=getActiveWindow();
      VALUE value=FXRbGetRubyObj(result,true);
      if(!NIL_P(value)){
        if(result){
          while(result->getFocus()){
            result=result->getFocus();
            }
          }
        return result;
        }
      return NULL;
      }
    

    And modify the FXRbWindow::markfunc() function in markfuncs.cpp from this:

    while(child!=NULL){
    

    to this:

    while((child!=NULL) && (!(NIL_P(FXRbGetRubyObj(child,true))))){
    
  • lyle (at lylejohnson)

    lyle (at lylejohnson) November 11th, 2009 @ 06:43 PM

    This solution requires patching FOX (replacing the implementation of getFocusWindow()) and that's something we need to avoid. Need to come up with an alternative solution.

  • lyle (at lylejohnson)

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

FXRuby is a library for developing powerful and sophisticated cross-platform graphical user interfaces (GUIs) for your Ruby applications. It’s based on the FOX Toolkit, a popular open source C++ library developed by Jeroen van der Zijp. What that means for you as an application developer is that you’re able to write code in the Ruby programming language that you already know and love, while at the same time taking advantage of the performance and functionality of a featureful, highly optimized C++ toolkit.

Shared Ticket Bins

People watching this ticket

Tags

Pages