Barnsley fern fractal

Thoughts on software architecture and development, and methods and techniques for improving the quality thereof.

David B. Robins (home)


Code Visions: Improving software quality
Startup crash in Windows dynamic loader

By David B. Robins tags: C++, Windows, Tools Saturday, September 2, 2017 11:21 EST (link)

>	ntdll.dll!LdrProcessRelocationBlockLongLong()	Unknown
 	ntdll.dll!LdrRelocateImageWithBias()	Unknown
 	ntdll.dll!LdrpProtectAndRelocateImage()	Unknown
 	ntdll.dll!LdrpRelocateImage()	Unknown
 	ntdll.dll!LdrpCompleteMapModule()	Unknown
 	ntdll.dll!LdrpMapDllWithSectionHandle()	Unknown
 	ntdll.dll!LdrpMapDllNtFileName()	Unknown
 	ntdll.dll!LdrpMapDllRetry()	Unknown
 	ntdll.dll!LdrpProcessWork()	Unknown
 	ntdll.dll!LdrpDrainWorkQueue()	Unknown
 	ntdll.dll!LdrpInitializeProcess()	Unknown
 	ntdll.dll!_LdrpInitialize()	Unknown
 	ntdll.dll!LdrpInitialize()	Unknown
 	ntdll.dll!LdrInitializeThunk()	Unknown

Not much of an entry after so long, but I couldn't find the symptoms of this problem anywhere else (although this had some similar elements, and remained unsolved).

I was doing some testing for a new product on Windows 7 (since we needed to support that, and so far I'd tested on my Windows dev machine, running Windows 10), and it kept crashing on startup in the NTDLL loader code (callstack above). It also only happened with release builds, and I narrowed it one of two (not including OS/runtime) DLLs we packaged, call it x.dll. I copied over a built debug x.dll, and all was fine (of course there are other problems mixing debug and release binaries, but I was just trying to get past this problem on load). Then I copied the release x.dll from the build location (it gets copied to a staging location to be packaged in the installer), and—also fine.

Then I recalled that for the Linux build, we strip binaries (using install -s) to remove unnecessary symbols and sections, and since Windows uses as much of the same makefile as possible (via Cygwin), it also tries to strip Windows DLLs, which is doing the wrong thing and causing the crash. Interestingly, whatever strip does on Windows, it does not change the file size.

Mystery solved, easy fix, on to bigger problems….

Content on this site is licensed under a Creative Commons Attribution 3.0 License and is copyrighted by the authors.