Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-10617

Windows debug libraries refer to "release" CRT instead of "debug" CRT and that causes crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Medium
    • Resolution: Clarified
    • Affects Version/s: 6.18/04
    • Fix Version/s: None
    • Component/s: Build System
    • Labels:
      None
    • Environment:

      Windows, VS2019

    • Development:

      Description

      Problem description:
      Root causes my program built in debug configuration to crash at memory deallocation.
      My code is like this:

      void my_function()
      {
      ...
        {
          std::vector<Something> v;
          my_dll_function(v); // <-- this one fills "v" with some data 
          ... do some stuff with v ...
         
        }
        // Here it crashes
      ...
      }
      

      my_dll_function is function inside DLL which I also build in debug mode.
      Normally debug mode programs refer to UCRTBASED.DLL, however debug Root libraries still refer to UCRTBASE.DLL (release one) - checked it with Dependency Walker.
      For some reason libcling.dll exports operator delete and linker links operator delete to the code in EXE instead of using standard one.
      So what happens:

      • Vector allocates its data storage inside DLL using UCRTBASED.DLL
      • Vector deallocates storage in the EXE using operator delete from libcling.dll which points to the UCRTBASE.DLL
      • Program crashed on the CRT heap assertion.

      Proof crash stack trace:

        ntdll.dll!_RtlReportCriticalFailure@8 () Unknown
        ntdll.dll!_RtlpHeapHandleError@4 () Unknown
        ntdll.dll!_RtlpLogHeapFailure@24 () Unknown
        ntdll.dll!RtlFreeHeap() Unknown
        ucrtbase.dll!_free_base() Unknown
        ucrtbase.dll!_free () Unknown
        libCling.dll!operator delete(void * block, unsigned int __formal) Line 31 C++
        MyApplication.exe!std::_Deallocate<8,0>(void * _Ptr, unsigned int _Bytes) Line 195	C++
        MyApplication.exe!std::allocator<Something>::deallocate(Something * const _Ptr, const unsigned int _Count) Line 780 C++
        MyApplication.exe!std::vector<Something,std::allocator<Something>>::_Tidy() Line 1701	C++
        MyApplication.exe!std::vector<HedgeLib_SymbolBrief,std::allocator<Something>>::~vector<Something,std::allocator<Something>>() Line 676 C++
        MyApplication.exe!my_function() Line 135 C++
      

      What needs to be done:

      • Please make sure all executables and DLLs in the "debug" version of Root are built with /MDD compiler switch instread of /MD (or no such switch at all - I am not familiar with Root build script and don't know what it uses exactly).
      • Issue new Root version with properly compiled stuff

        Attachments

          Activity

            People

            Assignee:
            bellenot Bertrand Bellenot
            Reporter:
            cc7044ed4393816a75a7 Ivan Pizhenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: