Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: James Russell <internationalhobo(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE
Date: 2007-01-24 02:55:23
Message-ID: 20070124025522.GA94027@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 23, 2007 at 09:09:52PM -0500, Tom Lane wrote:
> "James Russell" <internationalhobo(at)gmail(dot)com> writes:
> > If a text field contains a such a character, and if the search term contains
> > certain Unicode characters, then queries using ILIKE will crash the server.
>
> I can't reproduce this with your example, so I suppose there's some
> critical bit of information you've left out. Can you provide a stack
> trace from the crash?

This might be platform-dependent -- I get a crash with an 8.1.6
UTF-8 database on RHEL AS 4 x86_64 but not on Solaris 9/sparc 32-bit.
I don't get a crash on either platform with 8.2.1 or 8.3devel.

The crash seems to happen only with code points that have UTF-8
byte sequences of more than three bytes (U+10000 and higher).
Here's an example that segfaults in 8.1.6 on the Linux box:

select e'\360\220\200\200' ilike e'%\342\204\242';

#0 MBMatchTextIC (t=0x8ebcbc "�\220\200\200�7\212", tlen=4, p=0x0, plen=3) at like_match.c:195
195 if (ICHAREQ(t, p) || (*p == '\\') || (*p == '_'))
(gdb) bt
#0 MBMatchTextIC (t=0x8ebcbc "�\220\200\200�7\212", tlen=4, p=0x0, plen=3) at like_match.c:195
#1 0x00000000005ae558 in texticlike (fcinfo=Variable "fcinfo" is not available.
) at like.c:355
#2 0x0000000000501044 in ExecMakeFunctionResult (fcache=0x90b530, econtext=0x90b400, isNull=0x90bdb0 "", isDone=0x90bdd0) at execQual.c:1095
#3 0x0000000000504c23 in ExecProject (projInfo=0x90bbf0, isDone=0x7fbfffdd74) at execQual.c:3704
#4 0x000000000050f64a in ExecResult (node=0x90b2e8) at nodeResult.c:157
#5 0x00000000004ff90d in ExecProcNode (node=0x90b2e8) at execProcnode.c:306
#6 0x00000000004feb8a in ExecutorRun (queryDesc=Variable "queryDesc" is not available.
) at execMain.c:1122
#7 0x000000000058857e in PortalRunSelect (portal=0x908ae8, forward=Variable "forward" is not available.
) at pquery.c:794
#8 0x0000000000588b7f in PortalRun (portal=0x908ae8, count=9223372036854775807, dest=0x8ec510, altdest=0x8ec510, completionTag=0x7fbfffe0f0 "")
at pquery.c:646
#9 0x0000000000584846 in exec_simple_query (query_string=0x8eb4e8 "select e'\\360\\220\\200\\200' ilike e'%\\342\\204\\242';") at postgres.c:1004
#10 0x00000000005864ee in PostgresMain (argc=4, argv=0x8844a8, username=0x884390 "mfuhr") at postgres.c:3232
#11 0x000000000055c31a in ServerLoop () at postmaster.c:2863
#12 0x000000000055d90a in PostmasterMain (argc=5, argv=0x8828c0) at postmaster.c:941
#13 0x000000000051d5e3 in main (argc=5, argv=0x8828c0) at main.c:265

--
Michael Fuhr

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2007-01-24 03:24:51 Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE
Previous Message Tom Lane 2007-01-24 02:09:52 Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE