wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
ErwinH
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 05, 2015 6:05 am

wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by ErwinH »

I'm trying to use wxFreeChart 1.6 with wxWidgets 3.0.2 compiled with gcc under Windows.
There are two scenarios where no chart can be displayed and the demo app and/or the application using wxFreeChart crashes:

- Using gcc compiler optimization -O3 (demo app and user app)
- When deriving from wxChartPanel and creating an instance thereof (only user app)

When I use compiler optimization -O2, there is no crash. When I use the class wxChartPanel directly, there is no crash either.

Does anyone has found a similar behavior and/or has found where the problem is?
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by doublemax »

Which gcc version?
- Using gcc compiler optimization -O3 (demo app and user app)
Sounds like a compiler bug.
- When deriving from wxChartPanel and creating an instance thereof (only user app)
Hard to tell without seeing code.
Use the source, Luke!
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by iwbnwif »

Please check to make sure that your wxChartPanel is not being set to either wxSize(0,0) or wxDefaultSize (I can't remember which) because this was causing a lot of crashes for me.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
ErwinH
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 05, 2015 6:05 am

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by ErwinH »

I use mingw32 with gcc 4.7.2 compiler.

Regarding the second problem, I have found the problem. This is the test class that is derived from wxChartPanel:

Code: Select all

class MyChartPanel : public wxChartPanel
{
public:
	/**
	 * @brief Constructor.
	 *
	 * @param pParent Parent window.
	 * @param pId Window identifier. If <code>wxID_ANY</code> a new unique identifier is created.
	 * @param pPos Window position.
	 * @param pSize Window size.
	 */
	MyChartPanel( wxWindow *pParent, wxWindowID pId = wxID_ANY,
				  const wxPoint &pPos = wxDefaultPosition,
				  const wxSize &pSize = wxDefaultSize );
	/**
	 * @brief Destructor.
	 */
	virtual ~MyChartPanel();
};

// Implementation of constructor & destructor
MyChartPanel::MyChartPanel(	wxWindow *pParent, wxWindowID pId,
							const wxPoint &pPos,
							const wxSize &pSize )
//	: wxChartPanel(this, pId, NULL, pPos, pSize) {			// crash
	: wxChartPanel(pParent, pId, NULL, pPos, pSize) {		// no crash
	// nothing to do here
}

MyChartPanel::~MyChartPanel() {
	// nothing to do here
}
The problem was that I did not pass the parent window to wxChartPanel properly. So now I can derive from wxChartPanel with ease. :D
I did not see a problem with wxSize(0,0) or wxDefaultSize so far.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4183
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by PB »

ErwinH wrote:I did not see a problem with wxSize(0,0) or wxDefaultSize so far.
I noticed a similar issue with wxFreeChart and wxWidgets trunk, but it was "only" an assert for me, easily fixed:
https://github.com/pbfordev/wxFreeChart ... 872d6ffb4e
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Post by iwbnwif »

I noticed a similar issue with wxFreeChart and wxWidgets trunk, but it was "only" an assert for me, easily fixed:
https://github.com/pbfordev/wxFreeChart ... 872d6ffb4e
Ah yes, that is exactly it. Sorry, I forgot that they were only asserts.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Post Reply