Re: unsafe use of hash_search(... HASH_ENTER ...)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: unsafe use of hash_search(... HASH_ENTER ...)
Date: 2005-05-27 03:40:13
Message-ID: 10592.1117165213@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu> writes:
> In md.c/RememberFsyncRequest():

> if (hash_search(pendingOpsTable, &entry, HASH_ENTER, NULL) == NULL)
> ereport(FATAL,
> (errcode(ERRCODE_OUT_OF_MEMORY),
> errmsg("out of memory")));

> pendingOpsTable uses "MdCxt" to allocate memory. So if "out of memory", we
> actually have no chance to raise the error level to FATAL. A quick fix is to
> use malloc() HASH_ALLOC method for pendingOpsTable.

"Unsafe" is a bit of an overstatement, when you evidently haven't
analyzed the consequences of either choice of error level. That is,
why is this a bug?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-05-27 04:11:43 Re: Fix for timestamp rouding
Previous Message Qingqing Zhou 2005-05-27 03:27:15 unsafe use of hash_search(... HASH_ENTER ...)