From 0a2fb31daebd466137c77d5ebb031039efea20f4 Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Thu, 11 Apr 2024 14:21:40 +0300 Subject: [PATCH 1/2] Added assert to show bug #8079 --- src/jrd/jrd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 98f3900fda..d8e3a73ae7 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -9859,6 +9859,8 @@ void TrigVector::release() void TrigVector::release(thread_db* tdbb) { + fb_assert(useCount.value() > 0); + if (--useCount == 0) { decompile(tdbb); From a580a308c6bb785dfc1ab57bb0cdd7ba3f8514a9 Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Thu, 11 Apr 2024 14:22:47 +0300 Subject: [PATCH 2/2] Fixed bug #8079 : Engine could crash when executing some trigger(s) while another attachment modifies them --- src/jrd/exe.cpp | 10 ++-------- src/jrd/met.epp | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 7fef5d51b9..825b29aa41 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -1289,7 +1289,7 @@ void EXE_execute_triggers(thread_db* tdbb, * if any blow up. * **************************************/ - if (!*triggers) + if (!*triggers || (*triggers)->isEmpty()) return; SET_TDBB(tdbb); @@ -1297,7 +1297,7 @@ void EXE_execute_triggers(thread_db* tdbb, Request* const request = tdbb->getRequest(); jrd_tra* const transaction = request ? request->req_transaction : tdbb->getTransaction(); - TrigVector* vector = *triggers; + RefPtr vector(*triggers); Record* const old_rec = old_rpb ? old_rpb->rpb_record : NULL; Record* const new_rec = new_rpb ? new_rpb->rpb_record : NULL; @@ -1422,15 +1422,9 @@ void EXE_execute_triggers(thread_db* tdbb, trigger = NULL; } - - if (vector != *triggers) - MET_release_triggers(tdbb, &vector, true); } catch (const Exception& ex) { - if (vector != *triggers) - MET_release_triggers(tdbb, &vector, true); - if (trigger) { EXE_unwind(tdbb, trigger); diff --git a/src/jrd/met.epp b/src/jrd/met.epp index 252775860a..0f3bae45b8 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -1883,6 +1883,7 @@ void MET_load_ddl_triggers(thread_db* tdbb) attachment->att_ddl_triggers = FB_NEW_POOL(*attachment->att_pool) TrigVector(*attachment->att_pool); + attachment->att_ddl_triggers->addRef(); AutoRequest trigger_request;