This is an automated email from the ASF dual-hosted git repository.
jgemignani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-age.git
The following commit(s) were added to refs/heads/master by this push:
new d5cd568 Fix VLE local cache bug (crash)
d5cd568 is described below
commit d5cd56883da75bcf6d85f85b71f169cc5421a325
Author: John Gemignani <[email protected]>
AuthorDate: Thu May 26 13:49:19 2022 -0700
Fix VLE local cache bug (crash)
Fixed the VLE local cache. It had a bug that caused a circular loop
in the LRU cache list. This loop would then cause a crash when the
cache attempted to purge off old entries.
No impact on regression tests.
---
src/backend/utils/adt/age_vle.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/backend/utils/adt/age_vle.c b/src/backend/utils/adt/age_vle.c
index 30c7397..35d7e71 100644
--- a/src/backend/utils/adt/age_vle.c
+++ b/src/backend/utils/adt/age_vle.c
@@ -149,7 +149,7 @@ static void cache_VLE_local_context(VLE_local_context
*vlelctx);
static VLE_local_context *get_cached_VLE_local_context(int64
vle_grammar_node_id)
{
VLE_local_context *vlelctx = global_vle_local_contexts;
- VLE_local_context *prev = global_vle_local_contexts;
+ VLE_local_context *prev = NULL;
VLE_local_context *next = NULL;
int cache_size = 0;
@@ -162,10 +162,16 @@ static VLE_local_context
*get_cached_VLE_local_context(int64 vle_grammar_node_id
/* set the next pointer to the context that follows */
next = vlelctx->next;
- /* clear (unlink) the previous context's next pointer, if needed */
+ /*
+ * Clear (unlink) the previous context's next pointer, if needed.
+ * Also clear prev as we are at the end of avaiable cached contexts
+ * and just purging them off. Remember, this forms a loop that will
+ * exit the while after purging.
+ */
if (prev != NULL)
{
prev->next = NULL;
+ prev = NULL;
}
/* free the context */
@@ -217,7 +223,7 @@ static VLE_local_context
*get_cached_VLE_local_context(int64 vle_grammar_node_id
* If the context is good and isn't at the head of the cache,
* promote it to the head.
*/
- if (ggctx != NULL && vlelctx != prev)
+ if (ggctx != NULL && vlelctx != global_vle_local_contexts)
{
/* adjust the links to cut out the node */
prev->next = vlelctx->next;