Debug 3rd party DLL causing access violation after

2019-08-23 10:47发布

问题:

I know that mixing DLLs from different MSVC is bad and should be avoided...

I have a 3rd party DLL (XXX.dll, XXX.lib, XXX.h) which is implicitly linked in my application.

The original setup is:

  • My application (built with VS 2015)
  • XXX.dll (built with VS 2008)
  • x64
  • Windows 7

And it worked!

However moving to Windows 10: (My application is re-built with VS 2015 and still with XXX.dll)

Now the application keeps crash with access violation Exception thrown at 0x000001EF05A2BBB9 (XXX.dll) in Application.exe: 0xC0000005: Access violation reading location 0x00000000074A3A68.

Here is the call stack:

XXX.dll!000002a7eeb6bbb9()   
user32.dll!UserCallWinProcCheckWow()     
user32.dll!DispatchMessageWorker()   
mfc90u.dll!AfxInternalPumpMessage()  
mfc90u.dll!CWinThread::Run()     
mfc90u.dll!_AfxThreadEntry(pParam=0x000000d5452fd890)   
msvcr90.dll!_callthreadstartex()     
msvcr90.dll!_threadstartex(ptd=0x0000000000000000)   
kernel32.dll!BaseThreadInitThunk()   
ntdll.dll!RtlUserThreadStart()  

As usual, "3rd party" support is very unhelpful...

What could cause this problem suddenly on Win 10? What kind of mistake could XXX.dll!000002a7eeb6bbb9() make to mess up memory?

I was thinking about the problem mixing different CRT and it is the orignal question: different behavior when mixing DLLs from different MSVC