KindDragon / vld

Visual Leak Detector for Visual C++ 2008-2015
https://kinddragon.github.io/vld/
GNU Lesser General Public License v2.1
1.01k stars 314 forks source link

vld2.5.1 Application start up failed because of access violation VS2015 Update3 #51

Open Xuxiaotianonlyone opened 6 years ago

Xuxiaotianonlyone commented 6 years ago

Hello, could anyone help me?

There is a rare problem troubled me. I'm checking memory leak of my vs2015 solution with vld2.5.1. I have tried to check one simple vs2015 project,and the vld works well.But when I use vld to check our project that include about 100 subprojects, the generated application started up failed. (the application need to load some dlls) .

The phenomenon is a break dialog pop out and the info is a access vilolation exception: 0x0000000003241099 (vld_x64.dll) 0xC0000005: read location 0x00000000001C9D4A

This is the callstack info:

vld_x64.dll!FindRealCode(void pCode) 行 433 C++ vld_x64.dll!PatchImport(HINSTANCE__ importmodule, moduleentry_t patchModule) 行 551 C++ vld_x64.dll!PatchModule(HINSTANCE__ importmodule, moduleentry_t patchtable, unsigned int tablesize) 行 668 C++ vld_x64.dll!VisualLeakDetector::attachToLoadedModules(Set newmodules) 行 904 C++ vld_x64.dll!VisualLeakDetector::RefreshModules() 行 2332 C++ vld_x64.dll!LdrpCallInitRoutine(void BaseAddress, unsigned long Reason, void Context, unsigned char()(void , unsigned long, _CONTEXT *) EntryPoint) 行 98 C++

So,I tried to debug vld's source code to find the reason.And I found that in the utility.cpp in PatchImport function (line 489) ,when "importmodule == MagiQpdSrv_x64_nc_fw40_15001.dll " , program break off in LPVOID func = FindRealCode((LPVOID)thunk->u1.Function);(line 551).
At the same time, Function Parameter "(LPVOID)thunk->u1.Function" is a wild pointer. So program break off in function FindRealCode.

Does anyone know the solution for my problem?Thanks very much and look forward to a reply!

mxdamien commented 5 years ago

Hi Xuxiaotianonlyone, Hi everybody !

We are experiencing a similar issue. We have a project which loads several plugin dlls. When VLD is activated loading the DLLs causes the same exception in LoadLibrary() as described above. ( 0xC0000005 - access vilolation exception). We are using VS2015 with VLD 2.5.1 and are building in 32 Bit. The issue in Windows 7 64 Bit. My colleague using Windows 7 32 Bit has no problems.

vld_x86.dll!FindRealCode(void pCode) Line 433 C++ vld_x86.dll!PatchModule(HINSTANCE__ importmodule, moduleentry_t ) Line 666 C++ vld_x86.dll!VisualLeakDetector::attachToLoadedModules(Set newmodules) Line 902 C++ vld_x86.dll!VisualLeakDetector::RefreshModules() Line 2332 C++ vld_x86.dll!LdrpCallInitRoutine(void BaseAddress, unsigned long Reason, void Context, unsigned char(__stdcall)(void , unsigned long, _CONTEXT *) EntryPoint) Line 95 C++

jamesrwaugh commented 5 years ago

Hello all. My team recently had this problem with NUnit in 64-bit.

Not sure if this applies to the original issue, but for us the solution was to use VS Test (https://github.com/Microsoft/vstest) (from https://www.nuget.org/packages/Microsoft.TestPlatform.Portable/) with the NUnit adapter from NUnit, to run the NUnit tests, which VLD seems to have no issue attaching to, and FindRealCode has no issue.

yapingxin commented 5 years ago

I have the same issue. VLD 2.5.1 and VS2015 Update 3

'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\GLibDemo.exe'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\glib-2.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'D:\Apps\Dev\Visual_Leak_Detector\bin\Win64\vld_x64.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\pcred.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\libintl.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\libiconv.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'D:\Apps\Dev\Visual_Leak_Detector\bin\Win64\dbghelp.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'D:\GIT_ROOT\PHM-Prototype-190124\Dev\Build\MSVC_2015\Win32\Output\x64\Debug\libcharset.dll'. Symbols loaded. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Unloaded 'C:\Windows\System32\winmmbase.dll' 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\windows.storage.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\profapi.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\powrprof.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\umpdc.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. Cannot find or open the PDB file. 'GLibDemo.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file. Visual Leak Detector read settings from: D:\Apps\Dev\Visual_Leak_Detector\vld.ini Exception thrown at 0x0000000003241079 (vld_x64.dll) in GLibDemo.exe: 0xC0000005: Access violation reading location 0x00007FFC18EC28CE.

txal commented 2 years ago

The same problem, finally, I solve it by change the operating system encoding: don't use Unicode.