Able to trigger backend segmentation faults via tsearch2

Bug #141637 reported by Christian Reis
14
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
Stuart Bishop
PostgreSQL
Fix Released
Undecided
Unassigned
postgresql-8.2 (Ubuntu)
Fix Released
Medium
Martin Pitt
Nominated for Dapper by Martin Pitt
Feisty
Won't Fix
Undecided
Unassigned

Bug Description

An update issued to the Launchpad database uncovered a bug in PostgreSQL related to FTI; we were able to crash the backend when issuing a mass-update. We have established a simple testcase that reproduces the problem.

Revision history for this message
Christian Reis (kiko) wrote :

Tom, what we need to diagnose this is a script that simply tries to touch date_last_message (or any other field without touching description or one bug at a time, printing it out. We'll get this run on carbon and see what bug it is, and then we can investigate from there.

Changed in launchpad:
assignee: nobody → intellectronica
importance: Undecided → Critical
Revision history for this message
Eleanor Berger (intellectronica) wrote :

Can do, but I wonder, why would an update to the date_last_message column trigger a rebuild of the FTI? Shouldn't we make sure that this isn't the case?

Revision history for this message
Christian Reis (kiko) wrote : Re: [Bug 141637] Re: Updating FTI on one of our bugs causes PostgreSQL to SEGV

I'm pretty sure, but just updating the column and crashing will help us
find out if it's true or not.

Revision history for this message
Eleanor Berger (intellectronica) wrote : Re: Updating FTI on one of our bugs causes PostgreSQL to SEGV

bzr+ssh://devpad.canonical.com/code/tom.berger/launchpad/bug-141637/scripts/bug-141637.py

Changed in launchpad:
status: New → In Progress
Revision history for this message
Stuart Bishop (stub) wrote :

I tracked down one of the rows that triggers this and reported the bug upstream (Bug #144740).

I have a patch to fti.py that trims the text being indexed to the first 2500 characters of any field. This works around the issue, at least in the cases we have.

Revision history for this message
Christian Reis (kiko) wrote :

Dropped to medium as we have worked around the problem.

Changed in launchpad:
assignee: intellectronica → stub
importance: Critical → Medium
Revision history for this message
Christian Reis (kiko) wrote :

In the duplicate, Stuart uploaded a script which reproduces the problem with real-world data: http://launchpadlibrarian.net/9501485/crashme.sql

Revision history for this message
Scott Kitterman (kitterman) wrote :

Correcting postgresql package. postgresql was removed long ago.

Revision history for this message
Stuart Bishop (stub) wrote :

Erm... this is a duplicate of Bug #144740 if anything, not the other way around. This bug is on a launchpad specific crash. Bug #144740 is the superset of this one.

Revision history for this message
Christian Reis (kiko) wrote :

The Launchpad crash is the symptom, but it is the exact same bug. The right thing to do is update the summary and description to reflect this; I'll do that now.

description: updated
Revision history for this message
Christian Reis (kiko) wrote :
Changed in pgsql:
status: New → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

Upstream fix:

 http://developer.postgresql.org/cvsweb.cgi/pgsql/contrib/tsearch2/tsvector.c?r1=1.26&r2=1.26.2.1

This looks fine for an SRU, too. Reproduction recipe:

$ apt-get install postgresql-8.2 postgresql-contrib-8.2

# drop default cluster and create one with locale "C", to work with the reproducer script
$ sudo pg_dropcluster 8.2 main --stop
$ sudo pg_createcluster 8.2 main --locale C --start

$ run reproducer:
$ sudo -u postgres -i
$ createdb test
$ psql test -f crashme.sql

This will spin the CPU and hang for a while, until it eventually crashes.

Changed in postgresql-8.2:
assignee: nobody → pitti
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

postgresql-8.2 (8.2.5-1.1) gutsy; urgency=low

  * Upload bzr head to Gutsy to get the fix below quickly.
  * Add debian/patches/00upstream-tsearch2-compareWORD.patch:
    - Fix tsearch2's compareWORD() function to return 0 on identical strings.
      This avoids endless loops for situations where identical strings appear
      in sort lists (which Should Not Happen™, but do anyway).
    - Patch taken from upstream CVS:
      http://developer.postgresql.org/cvsweb.cgi/pgsql/contrib/tsearch2/tsvector.c?r1=1.26&r2=1.26.2.1
    - Thanks to Stuart Bishop for finding the bug and providing a reproducer.
    - (LP: #141637)

 -- Martin Pitt <email address hidden> Fri, 28 Sep 2007 15:12:33 +0200

Changed in postgresql-8.2:
status: In Progress → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Considering for SRU.

Revision history for this message
Martin Pitt (pitti) wrote :

FYI, I updated the dapper/8.2 backport for this bug fix, too:

  deb http://people.ubuntu.com/~pitti/packages/postgresql-8.2-dapper/ ./

Stuart Bishop (stub)
Changed in launchpad:
status: In Progress → Fix Released
Revision history for this message
LumpyCustard (orangelumpycustard) wrote :

Please close for Feisty as Won't Fix? This goes for all the other Feisty bugs.

Stuart Bishop (stub)
Changed in postgresql:
status: Fix Committed → Fix Released
Revision history for this message
Hew (hew) wrote :

Ubuntu Feisty Fawn is no longer supported, so a SRU will not be issued for this release. Marking Feisty as Won't Fix.

Changed in postgresql-8.2:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.