From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jeff Davis <pgsql(at)j-davis(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Minor cleanup for search path cache |
Date: | 2024-01-01 21:38:27 |
Message-ID: | 3972900.1704145107@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I happened to notice that there is a not-quite-theoretical crash
hazard in spcache_init(). If we see that SPCACHE_RESET_THRESHOLD
is exceeded and decide to reset the cache, but then nsphash_create
fails for some reason (perhaps OOM), an error will be thrown
leaving the SearchPathCache pointer pointing at already-freed
memory. Next time through, we'll try to dereference that dangling
pointer, potentially causing SIGSEGV, or worse we might find a
value less than SPCACHE_RESET_THRESHOLD and decide that the cache
is okay despite having been freed.
The fix of course is to make sure we reset the pointer variables
*before* the MemoryContextReset.
I also observed that the code seems to have been run through
pgindent without fixing typedefs.list, making various places
uglier than they should be.
The attached proposed cleanup patch fixes those things and in
passing improves (IMO anyway) some comments. I assume it wasn't
intentional to leave two copies of the same comment block in
check_search_path().
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
minor-search-path-cache-cleanup.patch | text/x-diff | 4.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dagfinn Ilmari Mannsåker | 2024-01-01 23:05:08 | Re: Assorted typo fixes |
Previous Message | Dian Fay | 2024-01-01 18:05:45 | Re: add function argument names to regex* functions. |