How It Works: SQL Server Stack Trace – COMDAT Elimination


Moved from: bobsql.com

 

Starting with​​ SQL Server ​​ 2019, SQL Server is​​ built with the​​ COMDAT, ICF linker option​​ enabled, reducing size/space usage. ​​ For example: binnsqllang.dll is ~12MB smaller when COMDAT is enabled.

 

Use ICF[=iterations] to perform identical COMDAT folding. ​​ /OPT:ICF can merge identical data or functions, it can change the function names that appear in stack traces.​​ 

 

I was looking​​ at a​​ strange​​ stack trace,​​ the caller​​ was not coded to invoke the displayed​​ destination​​ function. ​​ Here is an example:

class​​ C1

{

public:

 GetValue()

 {

  return​​ m_value;

 }

 

private:

 ULONGLONG m_timeStamp;

 ULONGLONG​​ m_value;

};

 

class​​ C2

{

public:

 GetId()

 {

  return​​ m_Id;

 }

 

private:

 char​​ m_name[8];

 ULONGLONG​​ m_Id;

};

 

main()

{

 C1​​ localVar;

 printf(« %lldn », c1.GetValue());

}