Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7222 Discussions

Unhandled Exception in Creating a DLL that Links to the MKL

coffeeachiever
Beginner
609 Views
Hi all,

I'm working with a friend's code. His project uses the MKL to create a DLL in Visual C++ 2005 that implements monte carlo to be used by Excel VBA. The problem is that Excel crashes when it uses the DLL.

Debugging his code, I traced the problem to an unhandled exception that occurs at this line:

errcode = vdRngGaussian(VSL_METHOD_DGAUSSIAN_BOXMULLER2, stream, 2, r, 0.0, 1.0);

I've never used the MKL and don't know much about it, but the parameter r is delcared as double r[2] and the parameter stream is declared as VSLStreamStatePtr stream. The return value, errcode, is an int.

The DLL is statically linked to the MKL since it's being distributed to analysts who don't have the MKL libraries. The libraries that are being linked in are:

odbc32.lib
odbccp32.lib
mkl_c.lib
mkl_sequential_dll.lib

There are no compiler/linker warnings or errors.

When the unhandled exception occurs, I get dumped in "memory" at checked_uninitialized_fill_n:

template class _Diff,
class _Tval,
class _Alloc> inline
void checked_uninitialized_fill_n(_FwdIt _First, _Diff _Count,
const _Tval& _Val, _Alloc& _Al)
{ // copy _Count *_Val to raw _First, using _Al
_STD _Uninit_fill_n(_First, _Count, _Val, _Al,
_STD _Ptr_cat(_First, _First), _STD _Checked_cat(_First));
}


Can someone help me out? I'm unfamiliar with the MKL, Visual C++, and Microsoft development in general. If this were an application, I could try to compile his code on my Linux box, but it's a Win32 DLL, filled with safearrays, variants, and other OLE datatypes.

Any help would be greatly appreciated!

Many thanks!
Pete


0 Kudos
2 Replies
g_f_thomas
Beginner
609 Views

So why not handle the exception, perform a traceback, and see where in the code hinted at by the debugger you actually wind up at? While not for the faint hearted, consult Richter's 'Windows via C++ Code' for details on how to use SEH. Excel might appear tohave crashed solely because an exception that arose in C/C++ code was not caught and fell through the cracks to be ultimately handled byExcel'smore primitiveexception handling abilities.

Gerry

0 Kudos
Andrey_G_Intel2
Employee
609 Views
Here is traditional mistake: it`s strictly prohibited to use statical MKL libraries in your DLLs. If you plan to use MKL in your ownd DLL you should use dynamical variant of MKL(you can use traditional MKL DLL or you can build your custom DLL _via_ custom DLL builder tool).
0 Kudos
Reply