Microsoft Developer Network > Forenhomepage > Visual C++ General > Changing PDB type causes crashes at runtime--linker bug?
Stellen Sie eine FrageStellen Sie eine Frage
 

FrageChanging PDB type causes crashes at runtime--linker bug?

  • Sonntag, 8. November 2009 08:27Jason C. Hughes TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code
    We're using VC 2005 SP1.

    I've spent two days tracking down a really severe problem that I've never seen before.  I have a gargantuan Solution with about 30 libraries, which I keep sane mainly by having .vsprops files for the project settings and manually delete out any overrides specified in the different .vcproj files.  (Trust me, this is a huge pain to keep clean.  I really wish there was an easier way.)

    We added about 5 new libraries recently to the build, and suddenly our debug build would run, but the release build would NOT.  Ok, typically this is a memory leak or uninitialized variable or something like that.  The problem is, I was getting a failure in a place that was very well tested.  After several hours of digging, I copied the debug property sheet file over the release .vsprops , except with NDEBUG instead of _DEBUG.  Everything worked fine, which means it was not a difference in the code, but a setting of some sort.  By process of careful elimination, I found that setting the PDB to Edit-And-Continue, our code seemed to link correctly.  Setting it to normal PDB, it fails.  Setting it to C7 fails.  Setting it to None fails.

    Here's the exact nature of the failure:  A string literal is being passed into a function and compared with another literal that is declared inside that function.  (This is actually ZLIB_VERSION check in zlib--very stable library.)  This comparison was failing because the pointer to the literal inside that function was pointing 36 bytes away from where it should in the data segment.  I'm guessing it's a weird linker bug.  I can't find any other circumstance or setting that we're using that could cause this.

    Additional information... we integrated a library recently that has only .lib and .pdb files to accompany the header files.  They didn't say what format the .pdb's were in.  Just to be sure this wasn't the cause of the issue, I tried building after deleting the .pdb files entirely and had the same crash/linker issue.

    The problem is, we can't reduce this to a smaller test situation.  All we can do is hope PDB Edit-And-Continue keeps working for us. 

    Question: Any ideas on what could cause this that we can address on our end?

    Question: Is there a cost for Edit-And-Continue that would make it unsuitable for a shipped executable?  If it's just executable space, we can live with that.

    Here is our (working) release .vsprops file, in case anything jumps out at you.  The only thing we have to change to make it fail is the DebugInformationFormat.

    <?xml version="1.0" encoding="Windows-1252"?>
    <VisualStudioPropertySheet
    	ProjectType="Visual C++"
    	Version="8.00"
    	Name="SPG properties"
    	OutputDirectory="$(SPG_BIN)"
    	IntermediateDirectory="$(SPG_TEMP)\obj\$(ConfigurationName)\$(ProjectName)"
    	>
    	<Tool
    		Name="VCBscMakeTool"
    		SuppressStartupBanner="true"
    		OutputFile="&quot;$(IntDir)\$(ProjectName).bsc&quot;"
    	/>
    	<Tool
    		Name="VCCLCompilerTool"
    		AdditionalOptions="/MP"
    		Optimization="0"
    		AdditionalIncludeDirectories="$(SPG_SRC)"
    		PreprocessorDefinitions="ENABLE_KEYBOARD;WIN32;NDEBUG;WIN32_LEAN_AND_MEAN"
    		MinimalRebuild="true"
    		RuntimeLibrary="0"
    		RuntimeTypeInfo="false"
    		PrecompiledHeaderThrough="shared/common/First.h"
    		PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
    		ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
    		BrowseInformation="1"
    		WarningLevel="4"
    		SuppressStartupBanner="true"
    		DebugInformationFormat="4"
    	/>
    	<Tool
    		Name="VCLibrarianTool"
    		OutputFile="&quot;$(IntDir)\$(ProjectName)-$(ConfigurationName).lib&quot;"
    		AdditionalLibraryDirectories="$(SPG_BIN);$(IntDir)"
    	/>
    	<Tool
    		Name="VCLinkerTool"
    		OutputFile="&quot;$(SPG_BIN)\$(ProjectName)-$(ConfigurationName).exe&quot;"
    		AdditionalLibraryDirectories="$(SPG_BIN);$(IntDir)"
    		GenerateManifest="true"
    		GenerateDebugInformation="true"
    		GenerateMapFile="true"
    		MapFileName="&quot;$(IntDir)\$(ProjectName)-$(ConfigurationName).map&quot;"
    		SubSystem="1"
    		TargetMachine="1"
    	/>
    </VisualStudioPropertySheet>
    
    


    Thanks,
    JH