Menu

#16 Unable to load DLLs from the application directory

Alpha
open
nobody
None
Core
58
all
2012-07-31
2012-07-31
No

This is a design problem that arises when instrumenting an EXE that uses a DLL residing in the same directory as the EXE (which is very common case). It arises both when the DLL is loaded at start time, or at runtime using LoadLibrary* without absolute file name.

The problem is that in many cases DLLs are searched first in the directory from which the application was loaded (see: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx). But when running under Valgrind, the application running is the Valgrind tool, not the program instrumented. Therefore, the directory of the Valgrind tool is searched for the DLL and not the directory where the instrumented program resides. As a result, loading of such a DLL fails.

This can easily be reproduced with one the following test programs:

coregrind\valgrind.exe memcheck\tests\windows\hellodll-amd64-windows-msvc.exe
coregrind\valgrind.exe memcheck\tests\windows\hellodll-x86-windows-msvc.exe

Valgrind will report one of:

Could not load 'hellothedll-amd64-windows-msvc.so.exe', error 126
Could not load 'hellothedll-x86-windows-msvc.so.exe', error 126

Discussion


Log in to post a comment.

MongoDB Logo MongoDB