8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Merge pull request #8080 from FirebirdSQL/work/gh-8079

Fix for bug #8079 : Engine could crash when executing some trigger(s) while another attachment modifies them
This commit is contained in:
Vlad Khorsun 2024-04-16 11:41:48 +03:00 committed by GitHub
commit d369e2ec26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 8 deletions

View File

@ -1289,7 +1289,7 @@ void EXE_execute_triggers(thread_db* tdbb,
* if any blow up. * if any blow up.
* *
**************************************/ **************************************/
if (!*triggers) if (!*triggers || (*triggers)->isEmpty())
return; return;
SET_TDBB(tdbb); SET_TDBB(tdbb);
@ -1297,7 +1297,7 @@ void EXE_execute_triggers(thread_db* tdbb,
Request* const request = tdbb->getRequest(); Request* const request = tdbb->getRequest();
jrd_tra* const transaction = request ? request->req_transaction : tdbb->getTransaction(); jrd_tra* const transaction = request ? request->req_transaction : tdbb->getTransaction();
TrigVector* vector = *triggers; RefPtr<TrigVector> vector(*triggers);
Record* const old_rec = old_rpb ? old_rpb->rpb_record : NULL; Record* const old_rec = old_rpb ? old_rpb->rpb_record : NULL;
Record* const new_rec = new_rpb ? new_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; trigger = NULL;
} }
if (vector != *triggers)
MET_release_triggers(tdbb, &vector, true);
} }
catch (const Exception& ex) catch (const Exception& ex)
{ {
if (vector != *triggers)
MET_release_triggers(tdbb, &vector, true);
if (trigger) if (trigger)
{ {
EXE_unwind(tdbb, trigger); EXE_unwind(tdbb, trigger);

View File

@ -9858,6 +9858,8 @@ void TrigVector::release()
void TrigVector::release(thread_db* tdbb) void TrigVector::release(thread_db* tdbb)
{ {
fb_assert(useCount.value() > 0);
if (--useCount == 0) if (--useCount == 0)
{ {
decompile(tdbb); decompile(tdbb);

View File

@ -1883,6 +1883,7 @@ void MET_load_ddl_triggers(thread_db* tdbb)
attachment->att_ddl_triggers = FB_NEW_POOL(*attachment->att_pool) attachment->att_ddl_triggers = FB_NEW_POOL(*attachment->att_pool)
TrigVector(*attachment->att_pool); TrigVector(*attachment->att_pool);
attachment->att_ddl_triggers->addRef();
AutoRequest trigger_request; AutoRequest trigger_request;