TeeChart crash with Japanese date/number/currency settings

TeeChart for ActiveX, COM and ASP
Post Reply
Tero
Newbie
Newbie
Posts: 10
Joined: Wed Mar 27, 2019 12:00 am
Contact:

TeeChart crash with Japanese date/number/currency settings

Post by Tero » Tue May 07, 2019 7:46 am

Change Windows' Date & time, number and currency settings to "Japanese (Japan)":

Format settings.png
Format settings.png (31.72 KiB) Viewed 41156 times

Create a program which uses GDIPlus (uses startup and shutdown). Create two charts with GDIPlus rendering disabled. When trying to disable GDIPlus rendering for the second chart a call to GDIPlusShutdown throws an exception.

OS: Windows 10
TeeChart 2019 ActiveX

A simple C++ test application included in .zip file.

Edit: If setting is f.ex. English application works as intended.
Attachments
TeeChart Crash.zip
(113.84 KiB) Downloaded 1584 times

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Fri May 31, 2019 3:05 pm

Hello,

We are checking this and will get back to this thread. We can reproduce the error and are testing a code fix to TeeChart.

Regards,
Marc Meumann
Steema Support

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Mon Jun 03, 2019 8:02 am


Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Mon Jun 03, 2019 8:24 am

Hello Tero,

We have emailed you a link to download a test version. Please inform us with feedback so we can be clear how to proceed.

With thanks.
Regards,
Marc
Steema Support

Tero
Newbie
Newbie
Posts: 10
Joined: Wed Mar 27, 2019 12:00 am
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Tero » Wed Oct 16, 2019 8:58 am

I tested this today because we have to consider switching back to GDI rendering because of area series drawing bugs with GDI+ rendering.

Unfortunately this did not fix the crash.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Tue Oct 22, 2019 8:12 am

Hi,

I'm unable to reproduce the problem with the latest version of TeeChart AX and the test project you sent in. Can you confirm please if the problem as you see it shows itself in the test project?

With thanks.
Regards,
Marc
Steema Support

Tero
Newbie
Newbie
Posts: 10
Joined: Wed Mar 27, 2019 12:00 am
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Tero » Mon Oct 28, 2019 9:13 am

I get the crash using latest TeeChart version (2019.00.7.23) using the test application I included earlier. Compiled both release and debug versions with VS2019 version 16.3.5. Both versions throw an exception from ntdll.dll when run as "Local Windows Debugger" from VS2019 IDE:

Code: Select all

void CTeeGDIPlus::GDIPlusShutdown()
{
this called =>:	InvokeHelper(0xcc, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}

try
{
	m_pChart2->GetAspect().GetGDIPlus().SetActive(false);
from here =>:	m_pChart2->GetAspect().GetGDIPlus().GDIPlusShutdown();
}
Japanese formatting settings selected. Windows version is Windows 10 Enterprise 1709.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Tue Nov 05, 2019 5:08 pm

A note on this to check.

GDIPlusShutdown should only be called once as it unloads the library (would also affect GDIPlus for the entire .exe). It shouldn't be unloaded if a call to GDIPlus methods is made after the call.

Another question. Your comment:
consider switching back to GDI rendering because of area series drawing bugs with GDI+ rendering
We can look at this. Is this something that's been reported elsewhere?

With thanks.
Regards,
Marc
Steema Support

Tero
Newbie
Newbie
Posts: 10
Joined: Wed Mar 27, 2019 12:00 am
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Tero » Mon Nov 11, 2019 8:34 am

Our app uses GDI+ rendering elsewhere even before TeeChart2019.ocx is loaded or any TeeChart objects have been created so we call GDIPlusStartup and GDIPlusShutdown. We call GDIPlusStartup in InitInstance method and GDIPlusShutdown in ExitInstance.

From Microsoft Dev Center documentation:
Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a DLL that uses GDI+, you should use one of the following techniques to initialize GDI+:
  • Require your clients to call GdiplusStartup before they call the functions in your DLL and to call GdiplusShutdown when they have finished using your DLL.
  • Export your own startup function that calls GdiplusStartup and your own shutdown function that calls GdiplusShutdown. Require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they have finished using your DLL.
  • Call GdiplusStartup and GdiplusShutdown in each of your functions that make GDI+ calls.
Our understanding is that you can call those functions as many times as you wish if calls do not "cross boundaries" (essentially solutions 2 & 3 in the list provided by Microsoft):

APP InitInstance: Startup
DLL : Startup
DLL: Shutdown
APP ExitInstance: Shutdown

Is OK.

APP InitInstace: Startup
DLL: Startup
APP ExitInstance: Shutdown
DLL: Shutdown

Is APP process is never terminated.

Problem is we cannot control when or how or if TeeChart2019.ocx calls GDIPlusStartup or GDIPlusShutdown and need TeeChart object to do so even if both of those were exported.

Best practise would be if TeeChart2019.ocx never calls GDIPlusStartup or GDIPlusShutdown but only our app does (first solution in the list provided by Microsoft). If you can suggest how we should use TeeChart from an app which uses GDI+ also elsewhere with any number (0 - unlimited) TeeChart objects created at any time please do so.

There is a bugtracker for the area drawing problem so do not worry about that.

BR,

Tero M.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Marc » Mon Nov 11, 2019 5:26 pm

Hello Tero,

Yes, the not crossing-boundaries should be valid. Our understanding of best practice when researching use of GDIPlus in an app that hosts a dll is to use nesting. ie. with the test code it might look something like this:

Code: Select all

CRect chart1Rect(rect);
chart1Rect.DeflateRect(0, 0, rect.Width() / 2, 0);

CRect chart2Rect(chart1Rect);
chart2Rect.MoveToXY(rect.Width() / 2, 0);

m_pChart1 = std::unique_ptr<CTChart>(new CTChart());
if (!m_pChart1->Create("Chart 1", WS_CHILD|WS_VISIBLE, chart1Rect, this, ID_CHART1))
	return -1;
try
{
	m_pChart2 = std::unique_ptr<CTChart>(new CTChart());
	if (!m_pChart2->Create("Chart 2", WS_CHILD | WS_VISIBLE, chart2Rect, this, ID_CHART2))
		return -1;
	try
	{
		m_pChart2->GetAspect().GetGDIPlus().SetActive(false);
		m_pChart2->GetAspect().GetGDIPlus().GDIPlusShutdown();
	}
	catch (CException* pE)
	{
		AfxMessageBox("Caught an exception when calling TeeChart GDIPlusShutdown() for chart 2.", MB_ICONERROR | MB_OK);
		return -1;
	}

	m_pChart1->GetAspect().GetGDIPlus().SetActive(false);
	m_pChart1->GetAspect().GetGDIPlus().GDIPlusShutdown();
}
catch (CException* pE)
{
	AfxMessageBox("Caught an exception when calling TeeChart GDIPlusShutdown() for chart 1.", MB_ICONERROR|MB_OK);
	return -1;
}
That does work ok in tests here. The other approach, the original test code, also works when debugging but fails in a straight run from the exe so it's making the tracking down of the cause difficult. Though we haven't yet confirmed why that might be it seems it may be related to the gdiplus token (and reuse of) that is being generated and freeing with shutdown. When the shutdown is nested that doesn't occur.

Picking up the original test after being parked some months. I hadn't noticed for my earlier feedback, that we'd left only the second gdiplus shutdown active; that works fine [in the test app] too. If possible to nest that would be the recommendation but you'd need to test it in the context of your main app.

We'll check further to see if we can improve our feedback on the issue.

Regards,
Marc
Steema Support

Tero
Newbie
Newbie
Posts: 10
Joined: Wed Mar 27, 2019 12:00 am
Contact:

Re: TeeChart crash with Japanese date/number/currency settings

Post by Tero » Wed Nov 13, 2019 5:34 am

The creation and destruction of charts is controlled by the user i.e. user creates data views and closes them at will so it is not possible to implement a system like in the example above (which is very simplistic example just to recreate the exception).

BR,

Tero M.

Post Reply