Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf45bdb1

Browse files
committed
Avoid possibly-theoretical OOM crash hazard in hash_create().
One place in hash_create() used DynaHashAlloc() as a convenientshorthand for MemoryContextAlloc(). That was fine when it waswritten, but it stopped being fine when9c911ec changedDynaHashAlloc() to use MCXT_ALLOC_NO_OOM (mea culpa). Changethe code to call plain MemoryContextAlloc() as intended.I think that this bug may be unreachable in practice, since we nowalways create AllocSets with some space already allocated, so thatan OOM failure here for a non-shared hash table should be impossible(with a hash table name of reasonable length anyway). And therearen't enough shared hash tables to make a crash for one of thoseprobable. Nonetheless it's clearly not operating as designed, soback-patch to v16 where9c911ec came in.Reported-by: Maksim Korotkov <m.korotkov@postgrespro.ru>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/219bdccd460510efaccf90b57e5e5ef2@postgrespro.ruBackpatch-through: 16
1 parent0de091a commitf45bdb1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎src/backend/utils/hash/dynahash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
388388
}
389389

390390
/* Initialize the hash header, plus a copy of the table name */
391-
hashp= (HTAB*)DynaHashAlloc(sizeof(HTAB)+strlen(tabname)+1);
391+
hashp= (HTAB*)MemoryContextAlloc(CurrentDynaHashCxt,
392+
sizeof(HTAB)+strlen(tabname)+1);
392393
MemSet(hashp,0,sizeof(HTAB));
393394

394395
hashp->tabname= (char*) (hashp+1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp