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

Commitfa5185b

Browse files
committed
Harden Memoization code against broken data types
Bug #17512 highlighted that a suitably broken data type could cause thebackend to crash if either the hash function or equality function were insomeway non-deterministic based on their input values. Such a data typecould cause a crash of the backend due to some code which assumes thatwe'll always find a hash table entry corresponding to an item in theMemoize LRU list.Here we remove the assumption that we'll always find the entrycorresponding to the given LRU list item and add run-time checks to verifywe have found the given item in the cache.This is not a fix for bug #17512, but it will turn the crash reported bythat bug report into an internal ERROR.Reported-by: Ales ZelenyReviewed-by: Tom LaneDiscussion:https://postgr.es/m/CAApHDvpxFSTwvoYWT7kmFVSZ9zLAeHb=S9vrz=RExMgSkQNWqw@mail.gmail.comBackpatch-through: 14, where Memoize was added.
1 parentbf4717b commitfa5185b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎src/backend/executor/nodeMemoize.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,13 @@ cache_reduce_memory(MemoizeState *mstate, MemoizeKey *specialkey)
446446
*/
447447
entry=memoize_lookup(mstate->hashtable,NULL);
448448

449-
/* A good spot to check for corruption of the table and LRU list. */
450-
Assert(entry!=NULL);
451-
Assert(entry->key==key);
449+
/*
450+
* Sanity check that we found the entry belonging to the LRU list
451+
* item. A misbehaving hash or equality function could cause the
452+
* entry not to be found or the wrong entry to be found.
453+
*/
454+
if (unlikely(entry==NULL||entry->key!=key))
455+
elog(ERROR,"could not find memoization table entry");
452456

453457
/*
454458
* If we're being called to free memory while the cache is being

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp