Hi All
I've just tested the situation with a fresh download of the latest plplot source using the test from Fulvio. As I'm on Windows I had to replace sleep(3) with Sleep(3000) and #include<windows.h>, but that should make no difference to the behaviour.
 
Without the patch the plot appears fine the first time, closes immediately if I right click off a plot and then fails when trying to access a null pointer when I try to display the plots again.
 
With the patch the plot appears fine the first time, closes immediately if I right click the plot. It then appears fine the second time, closes immediately when I right click off a plot - there is then a 3 second wait at the command line before the example exits. As far as I can tell this is exactly the expected behaviour. I've tested both release and debug builds.
 
I'm not really sure where to go next. It's not easy to fix a bug that I can't reproduced. Unfortunately I don't have the time at the moment to set up plplot on a linux machine.
Does someone happen to be able to run the test in a debugger e.g. by using Eclipse? In this case the debugger should catch the segfault and show the exact line where it occurs, and be able to see the call stack  (you may need the development version of wxWidgets with source code). On Windows it is in a wxwidgets file called toplevel in the CreateFrame member of a class called wxTopLevelWindowMSW. I guess it's not surprising the bug is slightly different on Linux then :-).
This was called by wxFrame::Create() which was in turn called by the wxFrame constructor. Fundamentally it's caused by the wxTheApp macro or wxApp::GetInstance() returning NULL because wxWidgets isn't initialised. Knowing where the crash occurs in linux and if it's for the same reason would be a good start at least.
 
Some possible lines of enquirey though if no one has access to a debugger. Maybe you could try these Fulvio
1) Which version of wxWidgets are you using? I have 2.8.10.
2) What is the behaviour if you close the first plot by clicking the x of selecting exit from the menu? For me this exits the entire application.
3) Try comment out lines 1396 and 1397 of wxwidgets.cpp - these should be wxPLGetApp().OnExit(); and plexit( "" );. Now what is the behaviour after closing the first window using the x or selecting Exit from the menu.
4) Finaly what is the behaviour for item 3 if the patch has been applied?
 
Sorry we're not at the root cause yet
 
Phil
 

From: Alan W. Irwin <irwin@beluga.phys.uvic.ca>
To: phil rosenberg <philip_rosenberg@yahoo.com>
Cc: fulvio ciriaco <fulvio.ciriaco@uniba.it>; "plplot-devel@lists.sourceforge.net" <plplot-devel@lists.sourceforge.net>; "fulviociriaco@users.sourceforge.net" <fulviociriaco@users.sourceforge.net>
Sent: Friday, 22 February 2013, 0:40
Subject: Re: [Plplot-devel] [ plplot-Bugs-3604554 ] wxwidgets window

On 2013-02-21 15:14-0800 phil rosenberg wrote:

> Thanks  for the report Fulvio
> In that case I will download a clean version of plplot tomorrow and check how it works with that. Unfortunately I do almost all my coding on a windows environment - mostly because the debugging tools are so good.
>  
> Speak soon
> Phil

Hi Phil:

I confirm fulvio's results on my own Debian (wheezy) system.  With
Fulvio's test.c example the wxwidgets (wxGC) GUI from the first plinit
does not disappear, and the second plinit segfaults.  These (bad)
results occur regardless of whether your wxwidgets patch is applied
or not.

So I suspect your wxwidgets patch (which, by the way, does apply
cleanly to the svn trunk version of PLplot) addresses part of the
issue but not all of it.

Will you try test.c yourself for testing purposes rather than your
modified x00c ?  I have attached a slightly modified form of it here
(plwid ==> plwidth is required for the trunk version) for your
convenience. Note I have tried this test.c for a number of interactive
devices and the only device where there are issues appears to be
wxwidgets.

Note, I normally run the default backend=2 (wxGC) but I also just now
tried -drvopt backend=0 (basic) and got the same (bad) results with
test.c.  I have not tried backend=1 (AGG) for the wxwidgets device
because the AGG library is not installed on my system.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________