Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c) - Mailing list pgsql-hackers

From Mahendra Singh Thalor
Subject Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)
Date
Msg-id CAKYtNAoUu1_jizdzP1qF7anW=ijN6MsP1eFPB7Qy7k4EL+x6UA@mail.gmail.com
Whole thread Raw
In response to Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)  (Ranier Vilela <ranier.vf@gmail.com>)
List pgsql-hackers
On Fri, 2 Jul 2021 at 01:13, Ranier Vilela <ranier.vf@gmail.com> wrote:
>
> Hi,
>
> The function FreePageManagerPutInternal can access an uninitialized variable,
> if the following conditions occur:

Patch looks good to me.

> 1. fpm->btree_depth != 0
> 2. relptr_off == 0 inside function (FreePageBtreeSearch)
>
> Perhaps this is a rare situation, but I think it's worth preventing.

Please can we try to hit this rare condition by any test case. If you have any test cases, please share.

1064 FreePageBtreeSearch(FreePageManager *fpm, Size first_page,                                                                                                                  
1065                     FreePageBtreeSearchResult *result)                          
1066 {                                                                              
1067     char       *base = fpm_segment_base(fpm);                                  
1068     FreePageBtree *btp = relptr_access(base, fpm->btree_root);                  
1069     Size        index;                                                          
1070                                                                                
1071     result->split_pages = 1;                                                    
1072                                                                                
1073     /* If the btree is empty, there's nothing to find. */                      
1074     if (btp == NULL)                                                            
1075     {                                                                          
1076         result->page = NULL;                                                    
1077         result->found = false;                                                  
1078         return;                                                                
1079     } 

>
> /* Search the btree. */
> FreePageBtreeSearch(fpm, first_page, &result);
> Assert(!result.found);
> if (result.index > 0)   /* result.index is garbage or invalid here) */
>
> regards,
> Ranier Vilela


--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: rand48 replacement
Next
From: Andrew Dunstan
Date:
Subject: Re: make world and install-world without docs