Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions
Date
Msg-id 49A80BE5.6010608@enterprisedb.com
Whole thread Raw
In response to Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
>> I think we should instead try to break the PANIC cycle. If we exceed
>> ERRORDATA_STACK_SIZE, and we're already PANICing, we should just die
>> immediately instead of throwing another PANIC about exceeding the stack
>> size. The attached patch does that.
>
> I don't think that's an improvement.
>
> I'm not sure exactly why the previous fix for this type of problem
> failed to cover this case --- did you identify why?

When the conversion function throws an ERROR, we try to send the error
message to the client. As part of that, we try to convert the text
"ERROR" to the client encoding (pq_sendstring does that). That calls the
conversion function again, which errors again, lathe, rinse, repeat.
until ERRORDATA_STACK_SIZE is reached. At that point, the same happens
with the text "PANIC", until ERRORDATA_STACK_SIZE is reached again, and
then we get into an endless recursion.

When the conversion function doesn't work, any attempt to send any text
to the client will fail.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions
Next
From: Tom Lane
Date:
Subject: Re: BUG #4680: Server crashed if using wrong (mismatch) conversion functions