Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE
Date
Msg-id 20070124025522.GA94027@winnie.fuhr.org
Whole thread Raw
In response to Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE
List pgsql-bugs
On Tue, Jan 23, 2007 at 09:09:52PM -0500, Tom Lane wrote:
> "James Russell" <internationalhobo@gmail.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE
Next
From: Tom Lane
Date:
Subject: Re: BUG #2895: Private Use Unicode character crashes server when using ILIKE