ereport bug

Поиск
Список
Период
Сортировка
Искать

ereport bug

От:
Dmitry Voronin <carriingfate92@yandex.ru>
Дата:
Hello, postgresmen!
 
I found incorrect execution of ereport() macro.
If we pass into ereport() function 2 or more arguments, the macro errcontext does not correct execute. So, ereport() call stack is:
 
errstart
errcontext_msg
set_errcontext_domain
errmsg
errfinish
pg_unreachable
 
This bug causes that error messages (for example, in PL/TCL) are not localized.

Solutions:
- Wrap all errcontext() macro in
brackets, that is errcontext("error message %s", "end message") -> (errcontext("error message %s", "end message"))
- Rewrite this macro
- ???
 
I am attaching to this letter a test case that shows the behavior errcontext() macro and the way to fix it.

I am using postgresql 9.4 and test it on gcc 4.7 and gcc 4.8.1.

-- Best regards, Dmitry Voronin

Re: ereport bug

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Dmitry Voronin  writes:
> 
Hello, postgresmen!
�
I found incorrect execution of ereport() macro.
If we pass into ereport() function 2 or more arguments, the macro errcontext does not correct execute. So, ereport() call stack is:
�
errstart
errcontext_msg
set_errcontext_domain
errmsg
errfinish
pg_unreachable
�
This bug causes that error messages (for example, in PL/TCL) are not localized.

Solutions:
- Wrap all errcontext() macro in
brackets, that is errcontext("error message %s", "end message") -> (errcontext("error message %s", "end message"))
- Rewrite this macro
- ???
�
I am attaching to this letter a test case that shows the behavior errcontext() macro and the way to fix it.

I am using postgresql 9.4 and test it on gcc 4.7 and gcc 4.8.1.

-- Best regards, Dmitry Voronin
(Please don't post HTML-only mail to the PG mailing lists ...) Hm ... the initial thought was that errcontext would never be used directly in an ereport() macro, but you're right that we now have some places that violate that rule. So the comma expression turns into a couple of arguments to errfinish, meaning the order of evaluation becomes compiler-dependent which is bad. I think the easiest fix is to have errstart initialize context_domain to the same value as domain. The order of evaluation is still compiler-dependent, but it no longer matters because any errcontext calls occurring textually within an ereport should be trying to select the same domain as the ereport anyway. regards, tom lane

Re: ereport bug

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin
 wrote:
> I am attaching to this letter a test case that shows the behavior
> errcontext() macro and the way to fix it.

So the upshot of this is that given errfinish(A, B, C), where A, B,
and C are expressions, my gcc is choosing to evaluate C, then B, then
A, then the errfinish call itself.  But whoever wrote the errcontext()
macro evidently thought, in this kind of situation, the compiler would
be certain to evaluate A, then B, then C, then errfinish.  But it
doesn't.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: ereport bug

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin
>  wrote:
>> I am attaching to this letter a test case that shows the behavior
>> errcontext() macro and the way to fix it.

> So the upshot of this is that given errfinish(A, B, C), where A, B,
> and C are expressions, my gcc is choosing to evaluate C, then B, then
> A, then the errfinish call itself.  But whoever wrote the errcontext()
> macro evidently thought, in this kind of situation, the compiler would
> be certain to evaluate A, then B, then C, then errfinish.  But it
> doesn't.

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a
		regards, tom lane


Re: ereport bug

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Wed, Jan 14, 2015 at 1:40 PM, Tom Lane  wrote:
> Robert Haas  writes:
>> On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin
>>  wrote:
>>> I am attaching to this letter a test case that shows the behavior
>>> errcontext() macro and the way to fix it.
>
>> So the upshot of this is that given errfinish(A, B, C), where A, B,
>> and C are expressions, my gcc is choosing to evaluate C, then B, then
>> A, then the errfinish call itself.  But whoever wrote the errcontext()
>> macro evidently thought, in this kind of situation, the compiler would
>> be certain to evaluate A, then B, then C, then errfinish.  But it
>> doesn't.
>
> http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a

Oops, sorry.  I missed that.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: ereport bug

От:
Воронин Дмитрий <carriingfate92@yandex.ru>
Дата:
Hello all

I see your patch, Tom. It works on my postgres 9.4 (intel x86_64). I write a letter if I can test it on others platform. 

Thank you!

14.01.2015, 21:40, "Tom Lane" :
> Robert Haas  writes:
>>  On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin
>>   wrote:
>>>  I am attaching to this letter a test case that shows the behavior
>>>  errcontext() macro and the way to fix it.
>>  So the upshot of this is that given errfinish(A, B, C), where A, B,
>>  and C are expressions, my gcc is choosing to evaluate C, then B, then
>>  A, then the errfinish call itself.  But whoever wrote the errcontext()
>>  macro evidently thought, in this kind of situation, the compiler would
>>  be certain to evaluate A, then B, then C, then errfinish.  But it
>>  doesn't.
>
> http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a
>
>                         regards, tom lane

-- 
С уважением, Дмитрий Воронин


FAQ