<div dir="ltr"><div><br></div><div>I recently upgraded from llvm 3.7.1 to a pre release of llvm (3.8.0rc2) in order to test some issues regarding bug 24233.</div><div>After upgrading I starting to see heap corruption messages in vs 2015 sp1 when my program exits. </div><div>"HEAP[ConsoleEngine.exe]: Invalid address specified to RtlValidateHeap( 0000000000290000, 0000000000318698 )" </div><div><br></div><div>Initially I only got it in Release build. Debug build seems to be fine, but recently I also got them in Debug build.</div><div>I traced it down how to trigger it in Debug Mode. It happens when I put the ExecutionEngine creation in the constructor in the cpp file.</div><div>If I put it in the h file then there's no problem. This leads me to believe that it is probably not my code that is causing it since I never seem to have</div><div>this issue in the past (3.6.x - 3.7.x). I've include the stack traces below this email.</div><div><br></div><div>It fails when the dtor is called for the first module. MCJIT only has 2 modules, the first one only has function declarations. The second one is empty. No codegen is taking place.</div><div><br></div><div>I googled for the error message and it seems to be happen when you delete a resource twice. </div><div>Did something change for 3.8.0 regarding to function decl. creation in a module? Any tips on how to trace it down further? I can't seem to make a small example demonstration the problem. It only seems to be triggered in a larger project (again: nearly code works fine in 3.6.x-3.7.x)</div><div><br></div><div><br></div><div>-- Release mode stack trace</div><div> <span class="" style="white-space:pre">      </span>ntdll.dll!RtlReportCriticalFailure()<span class="" style="white-space:pre">      </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!RtlpReportHeapFailure()<span class="" style="white-space:pre"> </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!RtlpHeapHandleError()<span class="" style="white-space:pre">   </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!RtlpLogHeapFailure()<span class="" style="white-space:pre">    </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!string "Enabling heap debug options\n"()<span class="" style="white-space:pre">      </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ucrtbase.dll!free()<span class="" style="white-space:pre">       </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ConsoleEngine.exe!llvm::Function::`vector deleting destructor'(unsigned int)<span class="" style="white-space:pre">  </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::Module::~Module(void)<span class="" style="white-space:pre">     </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::OwningModuleContainer::freeModulePtrSet(class llvm::SmallPtrSet<class llvm::Module *,4> &)<span class="" style="white-space:pre">       </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::~MCJIT(void)<span class="" style="white-space:pre">       </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::`vector deleting destructor'(unsigned int)<span class="" style="white-space:pre">     </span>C++</div><div><br></div><div><span class="" style="white-space:pre">       </span></div><div>-- Debug Mode stack trace</div><div><span class="" style="white-space:pre">   </span>ntdll.dll!RtlpBreakPointHeap()<span class="" style="white-space:pre">    </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!string "Enabling heap debug options\n"()<span class="" style="white-space:pre">      </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ntdll.dll!RtlValidateHeap()<span class="" style="white-space:pre">       </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>KernelBase.dll!HeapValidate()<span class="" style="white-space:pre">     </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ucrtbased.dll!_CrtIsValidHeapPointer()<span class="" style="white-space:pre">    </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ucrtbased.dll!_calloc_base()<span class="" style="white-space:pre">      </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ucrtbased.dll!_free_dbg()<span class="" style="white-space:pre"> </span>Unknown</div><div> <span class="" style="white-space:pre">  </span>ConsoleEngine.exe!operator delete(void * block) Line 21<span class="" style="white-space:pre">   </span>C++</div><div><span class="" style="white-space:pre">        </span>ConsoleEngine.exe!llvm::User::operator delete(void * Usr) Line 195<span class="" style="white-space:pre">        </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::Function::`scalar deleting destructor'(unsigned int)<span class="" style="white-space:pre">  </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::ilist_node_traits<llvm::Function>::deleteNode(llvm::Function * V) Line 160<span class="" style="white-space:pre">  </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::iplist<llvm::Function,llvm::SymbolTableListTraits<llvm::Function> >::erase(llvm::ilist_iterator<llvm::Function> where) Line 519<span class="" style="white-space:pre"> </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::iplist<llvm::Function,llvm::SymbolTableListTraits<llvm::Function> >::erase(llvm::ilist_iterator<llvm::Function> first, llvm::ilist_iterator<llvm::Function> last) Line 601<span class="" style="white-space:pre">        </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::iplist<llvm::Function,llvm::SymbolTableListTraits<llvm::Function> >::clear() Line 605<span class="" style="white-space:pre"> </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::Module::~Module() Line 61<span class="" style="white-space:pre"> </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::Module::`scalar deleting destructor'(unsigned int)<span class="" style="white-space:pre">    </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::OwningModuleContainer::freeModulePtrSet(llvm::SmallPtrSet<llvm::Module *,4> & MPS) Line 175<span class="" style="white-space:pre">      </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::OwningModuleContainer::~OwningModuleContainer() Line 82<span class="" style="white-space:pre">    </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::~MCJIT() Line 102<span class="" style="white-space:pre">  </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!llvm::MCJIT::`scalar deleting destructor'(unsigned int)<span class="" style="white-space:pre">     </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!std::default_delete<llvm::ExecutionEngine>::operator()(llvm::ExecutionEngine * _Ptr) Line 1195<span class="" style="white-space:pre">    </span>C++</div><div> <span class="" style="white-space:pre">      </span>ConsoleEngine.exe!std::unique_ptr<llvm::ExecutionEngine,std::default_delete<llvm::ExecutionEngine> >::~unique_ptr<llvm::ExecutionEngine,std::default_delete<llvm::ExecutionEngine> >() Line 1398<span class="" style="white-space:pre">  </span>C++</div><div><br></div></div>