diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-12-01 02:38:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-01 02:38:58 +0100 |
commit | ca28c455bfdc8408485c217c17f07011c0b43f64 (patch) | |
tree | 3dfa908fbaf0a3a1b9a3b6be101dd6a77d8160c1 /modules/mono/csharp_script.cpp | |
parent | b613c29053ef30a6be184aed6b9be5df46443db6 (diff) | |
parent | f6f2be7577f0f952c446064252339b7142109ea7 (diff) | |
download | redot-engine-ca28c455bfdc8408485c217c17f07011c0b43f64.tar.gz |
Merge pull request #24098 from neikeq/kk
Fix crash due to ~CSharpInstance() being called on freed instance
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index e3df0246ab..3c818898e6 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -993,7 +993,7 @@ void CSharpLanguage::set_language_index(int p_idx) { void CSharpLanguage::release_script_gchandle(Ref<MonoGCHandle> &p_gchandle) { - if (!p_gchandle->is_released()) { // Do not locking unnecessarily + if (!p_gchandle->is_released()) { // Do not lock unnecessarily SCOPED_MUTEX_LOCK(get_singleton()->script_gchandle_release_mutex); p_gchandle->release(); } @@ -1003,7 +1003,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, Ref<Mon uint32_t pinned_gchandle = MonoGCHandle::new_strong_handle_pinned(p_expected_obj); // We might lock after this, so pin it - if (!p_gchandle->is_released()) { // Do not locking unnecessarily + if (!p_gchandle->is_released()) { // Do not lock unnecessarily SCOPED_MUTEX_LOCK(get_singleton()->script_gchandle_release_mutex); MonoObject *target = p_gchandle->get_target(); @@ -1754,7 +1754,8 @@ CSharpInstance::CSharpInstance() : base_ref(false), ref_dying(false), unsafe_referenced(false), - predelete_notified(false) { + predelete_notified(false), + destructing_script_instance(false) { } CSharpInstance::~CSharpInstance() { @@ -1771,7 +1772,9 @@ CSharpInstance::~CSharpInstance() { if (mono_object) { MonoException *exc = NULL; + destructing_script_instance = true; GDMonoUtils::dispose(mono_object, &exc); + destructing_script_instance = false; if (exc) { GDMonoUtils::set_pending_exception(exc); |