Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9af2b34

Browse files
radixtree: Fix crash when non-creator begins iteration over shared tree.
Previously, if a backend that attached to a shared tree attempted to start iteration, it resulted in a crash. This commit resolves the issue by ensuring iter_context is created in RT_ATTACH(). This fix applies only to v17, where radixtree.h was introduced. In the master branch, this issue was separately resolved by 960013f, which eliminated the iter_context entirely. Reviewed-by: John Naylor Discussion: https://postgr.es/m/CAD21AoBB2U47V=F+wQRB1bERov_of5=BOZGaybjaV8FLQyqG3Q@mail.gmail.com
1 parent 32770ea commit 9af2b34

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/include/lib/radixtree.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,7 @@ RT_ATTACH(dsa_area *dsa, RT_HANDLE handle)
19021902
dsa_pointer control;
19031903

19041904
tree = (RT_RADIX_TREE *) palloc0(sizeof(RT_RADIX_TREE));
1905+
tree->context = CurrentMemoryContext;
19051906

19061907
/* Find the control object in shared memory */
19071908
control = handle;
@@ -1910,13 +1911,22 @@ RT_ATTACH(dsa_area *dsa, RT_HANDLE handle)
19101911
tree->ctl = (RT_RADIX_TREE_CONTROL *) dsa_get_address(dsa, control);
19111912
Assert(tree->ctl->magic == RT_RADIX_TREE_MAGIC);
19121913

1914+
/*
1915+
* Create the iteration context so that the attached backend also can
1916+
* begin the iteration.
1917+
*/
1918+
tree->iter_context = AllocSetContextCreate(CurrentMemoryContext,
1919+
RT_STR(RT_PREFIX) "_radix_tree iter context",
1920+
ALLOCSET_SMALL_SIZES);
1921+
19131922
return tree;
19141923
}
19151924

19161925
RT_SCOPE void
19171926
RT_DETACH(RT_RADIX_TREE * tree)
19181927
{
19191928
Assert(tree->ctl->magic == RT_RADIX_TREE_MAGIC);
1929+
MemoryContextDelete(tree->iter_context);
19201930
pfree(tree);
19211931
}
19221932

0 commit comments

Comments
 (0)