Skip to content

Commit

Permalink
Fix TrackCache memory crash
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Nov 23, 2023
1 parent fa4a653 commit b76be6f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,3 +2136,21 @@ AnimationMixer::AnimationMixer() {

AnimationMixer::~AnimationMixer() {
}

void AnimatedValuesBackup::set_data(const HashMap<NodePath, AnimationMixer::TrackCache *> p_data) {

Check failure on line 2140 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'AnimatedValuesBackup' has not been declared

Check failure on line 2140 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2140 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'AnimatedValuesBackup' has not been declared

Check failure on line 2140 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'struct AnimationMixer::TrackCache' is protected within this context
for (const KeyValue<NodePath, AnimationMixer::TrackCache *> E : p_data) {

Check failure on line 2141 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

loop variable 'E' creates a copy from type 'const KeyValue<NodePath, AnimationMixer::TrackCache *>' [-Werror,-Wrange-loop-construct]

Check failure on line 2141 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

loop variable 'E' creates a copy from type 'const KeyValue<NodePath, AnimationMixer::TrackCache *>' [-Werror,-Wrange-loop-construct]

Check failure on line 2141 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2141 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'struct AnimationMixer::TrackCache' is protected within this context
AnimationMixer::TrackCache *tc = memnew(AnimationMixer::TrackCache);

Check failure on line 2142 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2142 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2142 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2142 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'struct AnimationMixer::TrackCache' is protected within this context
memcpy(E.value, tc, sizeof(AnimationMixer::TrackCache));

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct AnimationMixer::TrackCache' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

destination for this 'memcpy' call is a pointer to dynamic class 'TrackCache'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

destination for this 'memcpy' call is a pointer to dynamic class 'TrackCache'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct AnimationMixer::TrackCache' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'struct AnimationMixer::TrackCache' is protected within this context

Check failure on line 2143 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct AnimationMixer::TrackCache' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
data[E.key] = tc;

Check failure on line 2144 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'data' was not declared in this scope; did you mean 'std::data'?

Check failure on line 2144 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'data' was not declared in this scope; did you mean 'std::data'?
}
}

HashMap<NodePath, AnimationMixer::TrackCache *> AnimatedValuesBackup::get_data() const {

Check failure on line 2148 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

'AnimatedValuesBackup' has not been declared

Check failure on line 2148 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

non-member function 'HashMap<NodePath, AnimationMixer::TrackCache*> get_data()' cannot have cv-qualifier

Check failure on line 2148 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

'AnimatedValuesBackup' has not been declared

Check failure on line 2148 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

non-member function 'HashMap<NodePath, AnimationMixer::TrackCache*> get_data()' cannot have cv-qualifier
HashMap<NodePath, AnimationMixer::TrackCache *> ret;
for (const KeyValue<NodePath, AnimationMixer::TrackCache *> E : data) {

Check failure on line 2150 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

loop variable 'E' creates a copy from type 'const KeyValue<NodePath, AnimationMixer::TrackCache *>' [-Werror,-Wrange-loop-construct]

Check failure on line 2150 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

loop variable 'E' creates a copy from type 'const KeyValue<NodePath, AnimationMixer::TrackCache *>' [-Werror,-Wrange-loop-construct]
AnimationMixer::TrackCache *tc = memnew(AnimationMixer::TrackCache);
memcpy(E.value, tc, sizeof(AnimationMixer::TrackCache));

Check failure on line 2152 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct AnimationMixer::TrackCache' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]

Check failure on line 2152 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

destination for this 'memcpy' call is a pointer to dynamic class 'TrackCache'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]

Check failure on line 2152 in scene/animation/animation_mixer.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

destination for this 'memcpy' call is a pointer to dynamic class 'TrackCache'; vtable pointer will be overwritten [-Werror,-Wdynamic-class-memaccess]
ret[E.key] = tc;
}
return ret;
}
4 changes: 2 additions & 2 deletions scene/animation/animation_mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ class AnimatedValuesBackup : public RefCounted {
HashMap<NodePath, AnimationMixer::TrackCache *> data;

public:
void set_data(const HashMap<NodePath, AnimationMixer::TrackCache *> p_data) { data = p_data; };
HashMap<NodePath, AnimationMixer::TrackCache *> get_data() const { return data; };
void set_data(const HashMap<NodePath, AnimationMixer::TrackCache *> p_data);
HashMap<NodePath, AnimationMixer::TrackCache *> get_data() const;

~AnimatedValuesBackup() {
for (KeyValue<NodePath, AnimationMixer::TrackCache *> &K : data) {
Expand Down

0 comments on commit b76be6f

Please sign in to comment.