[Tizen] Add more guard code to detect memory corruption 45/303145/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 20 Dec 2023 08:22:42 +0000 (17:22 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 20 Dec 2023 08:23:11 +0000 (17:23 +0900)
Change-Id: Ia4799ac86c49dbb515ad5c7fc13b3b6192773975
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.h

index 44ce798..5f9b299 100644 (file)
@@ -76,13 +76,14 @@ SvgVisual::SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory&
   mLoadFailed(false),
   mAttemptAtlasing(false)
 {
+  DALI_LOG_RELEASE_INFO("SvgVisual is created: %p, mImpl : %p, url : %s\n", this, mImpl, mImageUrl.GetUrl().c_str());
   // the rasterized image is with pre-multiplied alpha format
   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
 }
 
 SvgVisual::~SvgVisual()
 {
-  DALI_LOG_RELEASE_INFO("SvgVisual is destructed: %p, mLoadingTask : %p, mRasterizingTask : %p, url : %s\n", this, mLoadingTask.Get(), mRasterizingTask.Get(), mImageUrl.GetUrl().c_str());
+  DALI_LOG_RELEASE_INFO("SvgVisual is destructed: %p, mImpl : %p, mLoadingTask : %p, mRasterizingTask : %p, url : %s\n", this, mImpl, mLoadingTask.Get(), mRasterizingTask.Get(), mImageUrl.GetUrl().c_str());
   if(Stage::IsInstalled())
   {
     if(mLoadingTask)
index e270fa5..3d765dc 100644 (file)
@@ -159,6 +159,7 @@ Visual::Base::Base(VisualFactoryCache& factoryCache, FittingMode fittingMode, To
 : mImpl(new Impl(fittingMode, type)),
   mFactoryCache(factoryCache)
 {
+  mImplOrigin = mImpl;
 }
 
 Visual::Base::~Base()
@@ -659,6 +660,12 @@ void Visual::Base::DoSetOffScene(Actor& actor)
 
 bool Visual::Base::IsOnScene() const
 {
+  if(DALI_UNLIKELY(mImplOrigin != mImpl))
+  {
+    DALI_LOG_ERROR("Fatal error!! Memory corruption occured! this : %p\n", this);
+    DALI_LOG_ERROR("mImpl : %p, mImplOrigin : %p\n", mImpl, mImplOrigin);
+    DALI_ASSERT_ALWAYS(false && "Visual::Base might got memory corruption!");
+  }
   return mImpl->mFlags & Impl::IS_ON_SCENE;
 }
 
index 7ebf239..f03c64c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -511,6 +511,7 @@ private:
 protected:
   struct Impl;
   Impl*               mImpl;
+  Impl*               mImplOrigin{nullptr}; ///< Check for memory corruption
   VisualFactoryCache& mFactoryCache;
 };