0

I ran peverify on the Release build of a .dll and it gives me the error "Stack depth differs depending on path":

[IL]: Error: [C:\tfs\EcoSys\SCM\NextGenInstaller\Cmc.Installer\Cmc.Installer.Desktop\bin\Release\Cmc.Installer.Modules.Crm.dll : Cmc.Installer.Modules.Crm.Models.DatabaseInfo::set_Action][offset 0x0000007F] Stack depth differs depending on path.
1 Error(s) Verifying C:\tfs\EcoSys\SCM\NextGenInstaller\Cmc.Installer\Cmc.Installer.Desktop\bin\Release\Cmc.Installer.Modules.Crm.dll

The code for set_Action is as follows:

public InstallerAction Action
{
    get { return _action; }
    set
    {
        _action = value;

        InstallMainServer = false;
        InstallDistributorServer = false;
        InstallAnalyticsServer = false;
        InstallMediaServer = false;
        InstallWebTrakServer = false;

        switch (DatabaseType)
        {
            case DatabaseType.Main:
                InstallMainServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Distributor:
                InstallDistributorServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Analytics:
                InstallAnalyticsServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Media:
                InstallMediaServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.WebTrak:
                InstallWebTrakServer = (Action == InstallerAction.Install);
                break;
            default:
                throw new ArgumentOutOfRangeException("DatabaseType");
        }
    }
}

I have no idea why this error only occurs in a release build.

Mark Richman
  • 28,948
  • 25
  • 99
  • 159
  • That's a bug in the C# compiler. What version? – SLaks Aug 04 '14 at 21:11
  • Or the verifier :) Installers tend to do oddish things. It is a pretty serious mishap that nobody here can fix, turn to whomever was involved in the tools that compiled the code. Connect.microsoft.com if it was Microsoft, they'll need a repro project. – Hans Passant Aug 04 '14 at 22:16
  • Visual Studio 2013 / .NET 4.5.0 (both VS & TFS build). No installer involved here. I can repro at will locally. – Mark Richman Aug 04 '14 at 23:05
  • I filed a bug report here http://bit.ly/1s6kyGQ – Mark Richman Aug 04 '14 at 23:22

1 Answers1

1

While might not be directly related to the OP's problem, but I just ran into this error too. I was generating IL code for deserializing HashSet<T> - The problem was that the evaluation stack wasn't balanced as the Add method in HashSet<T> returns a bool, not void. So calling it will push a boolean that i didn't care about. Calling Pop right after the Add call fixed the problem.

            //T x; Deserialize(stream, out x, ctx);
            var x = emit.declocal(elementType);
            emit.ldarg_0()
                .ldloca_s(x)
                .ldarg_2()
                .call(deserialize);

            //value.Add(x);
            emit.ldarg_1()
                .ldind_ref()
                .ldloc_s(x)
                .call(add) // returns bool, since we're not using the value we need to pop the stack to keep the balance
                .pop();
vexe
  • 5,433
  • 12
  • 52
  • 81
  • I voted you up even though it's not the solution. I think there was a bug in Fody (https://github.com/Fody/PropertyChanged) which was causing the issue. It's since been resolved. – Mark Richman Mar 13 '15 at 18:03