[Rd] closing View windows after multiple View(x) crashes

Bill Dunlap bill at insightful.com
Tue Jul 29 21:59:05 CEST 2008


On Tue, 29 Jul 2008, Ben Bolker wrote:

>  > sessionInfo()
> R version 2.8.0 Under development (unstable) (2008-07-07 r46046)
> i686-pc-linux-gnu
> ...
> x = cbind(a=1:10,b=1:10)
>
> View(x)
> View(x)
> View(x)
> View(x)
>
>    then try to close the latest window by clicking on the "x"
> (close-window) icon in the corner.
>    I can usually provoke a segmentation fault this way ...
>    Ubuntu Hardy, up to date.

Does it work any better for you if you edit src/modules/X11/dataentry.c
and add a call to Rsync(DE) after the XDestroyWindow(iodisplay, DE->iowindow)
in closewin()?

I don't get your crash, but I have to click twice on the X button
to get the View window to close and valgrind complains about the use
of freed memory, DE->prot in the event loop in R_ProcessX11Events()
            if(ioevent.xclient.message_type == _XA_WM_PROTOCOLS
               && ioevent.xclient.data.l[0] == DE->prot) {
                /* user clicked on `close' aka `destroy' */
                done = 1;
            }
The trouble seems to be that this code sets done=1, causing the calls
        closewin(DE);
        free(DE);
but without the Rsync call in closewin(), the window doesn't close
immediately and later sends some messages to its event handler, causing
the use of the freed DE.  (I sometimes use the idiom free(DE);DE=NULL;
instead of just free(DE) to make sure no one tries to use DE afterwards,
but valgrind does that job better.)

When I make closewin() call Rsync(DE) then I only have to click
once on the X button to close the View window, the event loop
doesn't get reentered, and valgrind seems happy.

I'm using R on "Red Hat Enterprise Linux WS release 4 (Nahant Update 3)"
with the Cygwin X server on a Windows XP laptop.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."



More information about the R-devel mailing list