Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Segmentation Fault involving FXMessageBox and sockets

#11

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?"

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

State: new
Milestone: none
Assigned to: nobody

Activity

  1. lyle (at lylejohnson)
    lyle (at lylejohnson)

    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))))){
    

    November 11th, 2009 @ 06:40 PM

  2. lyle (at lylejohnson)
    lyle (at lylejohnson)

    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.

    November 11th, 2009 @ 06:43 PM

  3. 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.