okFrontPanel library causes Matlab to crash sometimes

Hello
We are running a rather extensive code in Matlab in which the program communicates with the FPGA board.
The code loads the okFrontPanel dll library at the startup. However sometimes when we run the code it causes Matlab to crash at the startup. The crashes are occasional and do not happen always.
If we wait sometime after opening Matlab and then run the code, then usually we do not see any crash.
We think the loading of the okFrontPanel library is the reason for occasional Matlab crashes because of overloading the memory.

Did anyone experience the same problem? Is there any way to avoid these occasional crashes?
l thought of putting a pause command at the beginning of my Matlab code to wait some time and then run the code but it did not prevent the crashes.

Thank You

Are you interacting with the DLL at all before you see the crash? Have you tried only loading the DLL?

The FrontPanel DLL doesn’t allocate any large buffers, so it should not be the cause of a memory issue.

Have you reached out to Mathworks to try to get some insight?

Hello and thanks for your response.
Yes , we are certain that the crash occurs, when the okFrontPanel library is being called. The following line is causing the crash:
calllib(‘okFrontPanel’, ‘okFrontPanel_GetWireInValue’, xptr, hex2dec(‘1F’), buf_mode);

Hi Kaveh,

We had a similar issue in matlab x64.

The problem was that the Matlab API referred to a 32-bit pointer in a 64-bit system. This resulted that sometimes matlab was crashing if the pointer was longer than the 32bits.

To resolve this, make sure that the matlab pointer is 64-bits long. You should already have changed the void* typdef in the file “Opal Kelly\FrontPanelUSB\API\include\okFrontPanelDLL.h” to an “usigned long”.

typedef unsigned long okPLL22150_HANDLE;
typedef unsigned long okPLL22393_HANDLE;
typedef unsigned long okFrontPanel_HANDLE;

Please make them 64 bit long by making them of type long long.

typedef long long okPLL22150_HANDLE;
typedef long long okPLL22393_HANDLE;
typedef long long okFrontPanel_HANDLE;

Our system did not crash anymore during start-up after this fix.

Can this maybe resolve your issue?

Hi Joost
Thanks so much.
It was the problem and it is now fixed! :grinning:

Hi Kaveh,

Thanks for you response. Good hear there are more people with this issue.