prevent encoding conversion recursive error

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-patches(at)postgresql(dot)org
Subject: prevent encoding conversion recursive error
Date: 2005-08-04 08:53:51
Message-ID: dcsl7c$284i$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

As this thread reports (some sever messages are in Chinese):

http://archives.postgresql.org/pgsql-bugs/2005-07/msg00247.php

a SQL grammar error could crash the error stack.

My explaination is that "select;" incurs a parse error and this error
message is
supposed to be translated into your encoding, but unfortunately not every
UTF8 character is necessarily be encoded as GB18030, which will cause an
infinite recursive elogs just like this:

1:elog(parse_error) // contain unencodable characters
2: elog(report_not_translatable) // contain unencodable characters
again
3: elog(report_report_not_translatable)
4: elog(report_report_report_not_translatable)
5: ...

and corrupt the elog stack.

To fix this, we just change errmsg() to errmsg_internal() to avoid
tranlation which could stop the recursion at step 2.

Regards,
Qingqing

---

Index: backend/utils/mb/conv.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/mb/conv.c,v
retrieving revision 1.53
diff -c -r1.53 conv.c
*** backend/utils/mb/conv.c 15 Jun 2005 00:15:08 -0000 1.53
--- backend/utils/mb/conv.c 4 Aug 2005 08:33:57 -0000
***************
*** 380,386 ****
{
ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
! errmsg("ignoring unconvertible UTF8
character 0x%04x",
iutf)));
continue;
}
--- 380,386 ----
{
ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
! errmsg_internal("ignoring unconvertible
UTF8 character 0x%04x",
iutf)));
continue;
}
***************
*** 449,455 ****
{
ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
! errmsg("ignoring unconvertible %s
character 0x%04x",

(&pg_enc2name_tbl[encoding])->name, iiso)));
continue;
}
--- 449,455 ----
{
ereport(WARNING,

(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
! errmsg_internal("ignoring
unconvertible %s character 0x%04x",

(&pg_enc2name_tbl[encoding])->name, iiso)));
continue;
}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2005-08-04 11:13:33 Re: Bug introduced by recent ALTER OWNER permissions check change
Previous Message Qingqing Zhou 2005-08-04 08:19:44 Re: Fundamental error in "no WAL log" index/file

Browse pgsql-patches by date

  From Date Subject
Next Message Matteo Beccati 2005-08-04 14:36:54 Enhanced containment selectivity function
Previous Message Tom Lane 2005-08-03 20:48:06 Re: PL/pgSQL: EXCEPTION NOSAVEPOINT