message: Fix a few cashes of WAVM teardown that can crash
diff: #include "Inline/Timing.h"
  #include "Logging/Logging.h"
  #include "RuntimePrivate.h"
  +#include "IR/Validate.h"
  #ifdef _DEBUG
  // This needs to be 1 to allow debuggers such as Visual Studio to place breakpoints and step through the JITed code.
  @@ -88,6 +89,7 @@ namespace LLVMJIT
  {
  UnitMemoryManager()
  : imageBaseAddress(nullptr)
  + , numAllocatedImagePages(0)
  , isFinalized(false)
  , codeSection({0})
  , readOnlySection({0})
  @@ -104,6 +106,7 @@ namespace LLVMJIT
  }
  // Decommit the image pages, but leave them reserved to catch any references to them that might erroneously remain.
  + if(numAllocatedImagePages)
  Platform::decommitVirtualPages(imageBaseAddress,numAllocatedImagePages);
  }
  @@ -228,6 +231,7 @@ namespace LLVMJIT
  }
  ~JITUnit()
  {
  + if(handleIsValid)
  compileLayer->removeModuleSet(handle);
  #ifdef _WIN64
  if(pdataCopy) { Platform::deregisterSEHUnwindInfo(reinterpret_cast<Uptr>(pdataCopy)); }
  @@ -266,6 +270,7 @@ namespace LLVMJIT
  std::unique_ptr<ObjectLayer> objectLayer;
  std::unique_ptr<CompileLayer> compileLayer;
  CompileLayer::ModuleSetHandleT handle;
  + bool handleIsValid = false;
  bool shouldLogMetrics;
  struct LoadedObject
  @@ -594,6 +599,7 @@ namespace LLVMJIT
  std::vector<llvm::Module*>{llvmModule},
  &memoryManager,
  &NullResolver::singleton);
  + handleIsValid = true;
  compileLayer->emitAndFinalize(handle);
  if(shouldLogMetrics)
  