Page 1 of 2

CPcanIsoTpExampleMFCthrowing exceptions

Posted: Wed 21. Feb 2018, 12:35
by devotip
The untouched fresh built demo is throwing exceptions when opening and closing. Any hint?

at startup
Exception thrown at 0x774843A9 (oleaut32.dll) in PcanIsoTpExampleMFC.exe: 0xC0000005: Access violation reading location 0x0000000C
callstack points to oleaut32.dll called by PCANBasic called by PCAN-ISO-TP

when closing
Exception thrown at 0x00591D08 in PcanIsoTpExampleMFC.exe: 0xC0000005: Access violation executing location 0x00591D08.
callstack not available

Environment is windows 7, visual studio 2015 update 3 latest PCAN libraries and demo from site

During runtime the USB-FD adapter is detected and early tests are looking ok

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Wed 21. Feb 2018, 16:45
by devotip
by the way there are a couple of C# leftover to clear out

str.Format(L"{0} {1} ({2:X2}h)", devDevice, byChannel, p_handle);
str.Format(L"An error occurred. Error-code's text ({0:X}) couldn't be retrieved", p_error);

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 10:44
by F.Vergnaud
Hello devotip,

We were able to reproduce your issue by placing the wrong PCAN-ISO-TP dll (i.e. the x64 version while running the x86 sample). Make sure the PCAN-ISO-TP dll located in your Debug/Release folders matches the building architecture (the sample is configured as a 32 bits application by default).

Thanks for the feedback about the string format functions, it will be fixed but for now it should not impact you in any way.

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 12:17
by devotip
PC is a win7 x64, the demo is x86 and the libraries in use (debug folder) are the ones defined in the attachment

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 12:35
by F.Vergnaud
In project file "stdafx.h", there is an include of <vld.h> (Visual Leak Dectector) on line 11. There are some known issues depending on the version installed that could match your problem. Since it is for debugging purpose only, could you comment/remove this include and let me know.

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 13:01
by devotip
Done, behavior unchanged

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 15:23
by F.Vergnaud
There is indeed an issue on Windows 7 with VS2015.3. You can fix the starting exception by using the corrected stdafx.h file, here is the changes up to the end of file:

Code: Select all


[...]

#include <vector>
#include "PCAN-ISO-TP.h"
#include "MappingStatus.h"
#include "MessageStatus.h"
#include "PCanIsoTpUtils.h"
#include "PCanIsoTpExampleDlgAddNewMappings.h"
#include "PCanIsoTpExampleDlgMappings.h"
#include "PCanIsoTpExampleDlgMessages.h"
#include "PCanIsoTpExampleDlgParameters.h"
#include "PCanIsoTpExampleTabCtrl.h"
#include "PcanIsoTpExampleDlg.h"
We are still investigating why there is an exception when the program exits.

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Thu 22. Feb 2018, 18:25
by devotip
Retrieved a vs2008 and setup a minimal dialog application, same issue when closing even without invoking anything

Another sample application PCTPClient is not exposing the effect but is a console only and may have a implied different shutdown sequence

As a side note the lib files included in the samples are not binary twins

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Sat 3. Mar 2018, 08:25
by devotip
Attached a minimal vs2008 MFC testcase, can be imported in newer visual studio versions
Start it, click cancel. nothing is invoked but crash when closing
Start it, click ok. CANTP_Uninitialize is invoked but crash when closing

start it, click libinfo. some methods are invoked and behaving as expected but then when closing a crash

Re: CPcanIsoTpExampleMFCthrowing exceptions

Posted: Mon 5. Mar 2018, 17:20
by F.Vergnaud
Hello Devotip,

Sorry for the delay, but the issue should be fixed in the next release. Meanwhile I'll see that you get a testing version to confirm the fix in the next few days.
I can confirm that the problem does not impact any of PCAN-ISO-TP features, it is only limited to the closure of an MFC application: the problem arises when Windows unloads PCANBasic.dll which is still used by PCAN-ISO-TP.dll.