CPcanIsoTpExampleMFCthrowing exceptions

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Wed 21. Feb 2018, 12:35

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

devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Wed 21. Feb 2018, 16:45

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);

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by F.Vergnaud » Thu 22. Feb 2018, 10:44

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.
Best regards,
Fabrice

devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Thu 22. Feb 2018, 12:17

PC is a win7 x64, the demo is x86 and the libraries in use (debug folder) are the ones defined in the attachment
Attachments
library versions
library versions
libs.jpg (110.93 KiB) Viewed 3007 times

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by F.Vergnaud » Thu 22. Feb 2018, 12:35

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.
Best regards,
Fabrice

devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Thu 22. Feb 2018, 13:01

Done, behavior unchanged

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by F.Vergnaud » Thu 22. Feb 2018, 15:23

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.
Attachments
stdafx.h
(2.3 KiB) Downloaded 261 times
Best regards,
Fabrice

devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Thu 22. Feb 2018, 18:25

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

devotip
Posts: 8
Joined: Tue 31. Oct 2017, 08:38

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by devotip » Sat 3. Mar 2018, 08:25

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
Attachments
CollaudoFSK.7z
Minimal MFC test case
(1.95 MiB) Downloaded 127 times

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: CPcanIsoTpExampleMFCthrowing exceptions

Post by F.Vergnaud » Mon 5. Mar 2018, 17:20

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.
Best regards,
Fabrice

Locked