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

How do I stop MKL from searching for libimalloc.dll?

tennican
Beginner
890 Views
My fairly small custom MKL library searches for this dll.
However, I do not want to use custom memory allocation and do not include libimalloc.dll with my application.
So, since the search causes a security vulnerability, I'd like to stop this behavior.
Can anyone tell me how I can compile a custom MKL library that will NOT do this search?

thanks, Scott
0 Kudos
6 Replies
barragan_villanueva_
Valued Contributor I
890 Views
Hi,

Please try to delete the whole line in the makefile which extracts i_malloc_dll.obj
lib .... /EXTRACT:i_malloc_dll.obj ...

And compile/use instead the following source file:

#include

i_malloc_t i_malloc = malloc;
i_calloc_t i_calloc = calloc;
i_realloc_t i_realloc = realloc;
i_free_t i_free = free;

void i_malloc_init(void) {}

0 Kudos
tennican
Beginner
890 Views
Cool, thanks for answering.
I'll give that I try as soon as I get time and let you know how it goes.
0 Kudos
tennican
Beginner
890 Views
Hi Victor,

So, I think you intend that I create a .c file containing the source above, compile it to an .obj file and reference it from a link line in the makefile.
Is that right?

So, I made a file called removeimalloc.c.
Created removeimalloc.obj using: cl /c removeimalloc.c
Added "removeimalloc.obj" right before the reference to $(CB_XERBLA) in the ia32 section since that's what I'm building.
Rebuilt mkl_custom.dll/lib.
Rebuilt my application using the new mkl_custom.dll/lib
Ran the application and watched it with Process Monitor.

Sadly, it appears the application is still using libimalloc.dll

Did I do everything the way you think I should?
Why do you think the problem persists?

thanks, Scott
0 Kudos
barragan_villanueva_
Valued Contributor I
890 Views
Scott,

Did youdelete the following lines in the makefile:
lib .... /EXTRACT:i_malloc_dll.obj ...
Also, it would be correct to delete all obj-file in that directory to not add unneeded stuff to your custom library
0 Kudos
tennican
Beginner
890 Views
Hi Victor,

Yup, I deleted:
@lib .\lib\mkl_cdll_ia32.lib /EXTRACT:i_malloc_dll.obj /OUT:.\temp_cdll\i_malloc_dll.obj

And changed:
.\temp_cdll\*.obj $(CB_XERBLA) \
To:
.\temp_cdll\*.obj .\removeimalloc.obj $(CB_XERBLA) \

Also, there are no other obj files the build directory.

thanks, Scott
0 Kudos
Julia_S_Intel1
Employee
890 Views
Hi Scott,

Could you please check your changes once more?

Here's output from Dependency Walker when MKL function i_malloc was used:

GetProcAddress(0x0000000077150000 [NTDLL.DLL], "NtQuerySystemInformation") called from "LIBIOMP5MD.DLL" at address 0x000000001006E1E7 and returned 0x00000000771A1670.
DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x00000000736F26F4) in "LIBIOMP5MD.DLL" returned 1 (0x1).
DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x0000000010071A40) in "MKL_CUSTOM.DLL" called.
LoadLibraryA("libimalloc.dll") called from "MKL_CUSTOM.DLL" at address 0x0000000180001015.
LoadLibraryA("libimalloc.dll") returned NULL. Error: The specified module could not be found (126).

DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x0000000010071A40) in "MKL_CUSTOM.DLL" returned 1 (0x1).

And here's output when the library was built withchanges suggested by Victor, there's no libimalloc:

GetProcAddress(0x0000000077150000 [NTDLL.DLL], "NtQuerySystemInformation") called from "LIBIOMP5MD.DLL" at address 0x000000001006E1E7 and returned 0x00000000771A1670.
DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x00000000736F26F4) in "LIBIOMP5MD.DLL" returned 1 (0x1).
DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x0000000010071A40) in "MKL_CUSTOM.DLL" called.
DllMain(0x0000000077255468, DLL_PROCESS_DETACH, 0x0000000010071A40) in "MKL_CUSTOM.DLL" returned 1 (0x1).


0 Kudos
Reply