From 7548c262ba4f7007e2e0143b3abbc8455dc46745 Mon Sep 17 00:00:00 2001 From: livecodepanos Date: Sun, 15 Sep 2019 23:35:50 +0300 Subject: [PATCH 1/2] Updated ide submodule ptr --- ide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide b/ide index 9c2d5ee528d..e61fa892f0b 160000 --- a/ide +++ b/ide @@ -1 +1 @@ -Subproject commit 9c2d5ee528db61bff0cdc04b51b4319072046ee1 +Subproject commit e61fa892f0b647b7138725ebec3118e7c3ec2bb5 From 41fe259d56c42ff0bb82a04c4f66019b082c6019 Mon Sep 17 00:00:00 2001 From: Mark Waddingham Date: Thu, 3 Oct 2019 08:46:14 +0100 Subject: [PATCH 2/2] [[ Bug 22130 ]] Disable deleted object pool creation whilst debugging This patch adds a 'freeze' count to the deleted object pool logic. When the current pool is frozen, no new pools will be created until it is thawed again. This means that all objects that are deleted during that period are accumulated in the frozen pool. This ability is used inside MCB_prepmessage, which is the handler which causes the engine to enter debug mode and send a message. Doing this prevents corruption of the deleted object pools stack which appears to occur when the script editor manipulates menus in the context of a debug-related message. As the use of freezing the current object pool is only used in this one place it has no effect on normal running code, only on code which runs in the context of a debug-related message. --- docs/notes/bugfix-22130.md | 1 + engine/src/debug.cpp | 4 +++- engine/src/object.cpp | 19 +++++++++++++++++++ engine/src/object.h | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 docs/notes/bugfix-22130.md diff --git a/docs/notes/bugfix-22130.md b/docs/notes/bugfix-22130.md new file mode 100644 index 00000000000..4f8c4596a74 --- /dev/null +++ b/docs/notes/bugfix-22130.md @@ -0,0 +1 @@ +# Improve stability of breakpoint manipulation in the S/E whilst debugging diff --git a/engine/src/debug.cpp b/engine/src/debug.cpp index 3631bee9cc7..a5fcf6451ec 100644 --- a/engine/src/debug.cpp +++ b/engine/src/debug.cpp @@ -284,7 +284,9 @@ void MCB_prepmessage(MCExecContext &ctxt, MCNameRef mess, uint2 line, uint2 pos, p3.setnext(&p4); p4.setvalueref_argument(p_info); } - MCB_message(ctxt, mess, &p1); + MCDeletedObjectsFreezePool(); + MCB_message(ctxt, mess, &p1); + MCDeletedObjectsThawPool(); if (id != 0) MCeerror->clear(); if (added) diff --git a/engine/src/object.cpp b/engine/src/object.cpp index ba06d055ad4..7e0d927c8a7 100644 --- a/engine/src/object.cpp +++ b/engine/src/object.cpp @@ -5519,6 +5519,7 @@ struct MCDeletedObjectPool static MCDeletedObjectPool *MCsparedeletedobjectpool = nil; static MCDeletedObjectPool *MCdeletedobjectpool = nil; static MCDeletedObjectPool *MCrootdeletedobjectpool = nil; +static uint32_t MCdeletedobjectpoolfreezedepth = 0; static bool MCDeletedObjectPoolCreate(MCDeletedObjectPool*& r_pool) { @@ -5604,8 +5605,22 @@ void MCDeletedObjectsTeardown(void) } } +void MCDeletedObjectsFreezePool(void) +{ + MCdeletedobjectpoolfreezedepth += 1; +} + +void MCDeletedObjectsThawPool(void) +{ + MCdeletedobjectpoolfreezedepth -= 1; +} + void MCDeletedObjectsEnterWait(bool p_dispatching) { + // If the current pool is frozen, do nothing + if (MCdeletedobjectpoolfreezedepth > 0) + return; + // If this isn't a dispatching wait, then no objects can be created. if (!p_dispatching) return; @@ -5632,6 +5647,10 @@ void MCDeletedObjectsEnterWait(bool p_dispatching) void MCDeletedObjectsLeaveWait(bool p_dispatching) { + // If the current pool is frozen, do nothing + if (MCdeletedobjectpoolfreezedepth > 0) + return; + // If this isn't a dispatching wait, then no objects can be created. if (!p_dispatching) return; diff --git a/engine/src/object.h b/engine/src/object.h index 49521f35c22..77c667f8768 100644 --- a/engine/src/object.h +++ b/engine/src/object.h @@ -506,6 +506,8 @@ struct MCExecValue; struct MCDeletedObjectPool; void MCDeletedObjectsSetup(void); void MCDeletedObjectsTeardown(void); +void MCDeletedObjectsFreezePool(void); +void MCDeletedObjectsThawPool(void); void MCDeletedObjectsEnterWait(bool p_dispatching); void MCDeletedObjectsLeaveWait(bool p_dispatching); void MCDeletedObjectsOnObjectCreated(MCObject *object);