[Tizen] Add more guard code to detect memory corruption accepted/tizen/unified/20231228.165707 accepted/tizen/unified/riscv/20240103.054613
authorsunghyun kim <scholb.kim@samsung.com>
Wed, 27 Dec 2023 07:06:17 +0000 (16:06 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Wed, 27 Dec 2023 07:06:21 +0000 (16:06 +0900)
This reverts commit 7e18ac19069e023e36f4f19c480991b4ef631cbb.

dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.h

index e270fa5..4522c78 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);
+  }
   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;
 };