DBD::Pg 'lo_read' fails on >= 32768 byte large objects

From: Kevin Houle <kjh(at)cert(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Cc: dbdpg-general(at)svr3(dot)postgresql(dot)org
Subject: DBD::Pg 'lo_read' fails on >= 32768 byte large objects
Date: 2003-08-14 19:11:27
Message-ID: 27950000.1060888287@discus.blue.cert.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

There appears to be a bug in the code used by DBD::Pg's 'lo_read'
function. I presume the code with the bug is a part of libpq, and
thus the postgresql-libs RPM binary distribution.

The nature of the bug is that an 'lo_read' operation performed
with DBD::Pg caused a segfault with postgresql-libs-7.3.2 and
"hangs" on files >= 32768 bytes with postgresql-libs-7.3.4. The
hang is actually a read() loop on the socket generating EAGAIN
error on each read().

I've attached a short perl script that demonstrates the bug.
The database server does not seem to matter; I get the same results
using 7.2 as I do with 7.3.x servers. I also get the same results
when I vary the perl-DBD-Pg and perl-DBI module versions. The bug
seems to be following libpg.

All of my testing has been on the i686 platform using linux 2.4.20
kernels.

Test case #1:
- client = postgresql-libs-7.2.3-5 (redhat-7.3)
perl-DBI-1.21-1 (redhat-7.3)
perl-DBD-Pg-1.01-8 (redhat-7.3)
perl-5.6.1
- server = postgresql-server-7.3.2-3 (redhat-9)
- transport = tcpip + ssl

$ perl test.pl
- reading testfile '/bin/ls'
- inserting testfile contents
- oid = '16265435'
- reading large object
success.. removing large object

Test case #2:
- client = postgresql-libs-7.3.2-3 (redhat-9)
perl-DBI-1.32-5 (redhat-9)
perl-DBD-Pg-1.21-2 (redhat-9)
-server = postgresql-server-7.3.2-3 (redhat-9)
-transport = tcpip + ssl

$ perl test.pl
- reading testfile '/bin/ls'
- inserting testfile contents
- oid = '16265436'
- reading large object
Segmentation fault

... after ~32768 bytes, process loops reading the socket
read(3, 0x81cc938, 5) = -1 EAGAIN (Resource temporarily unavailable)
and eventually segfaults

Test case #3:
- same as #2 except
- transport = tcpip (localhost)

$ perl test.pl
- reading testfile '/bin/ls'
- inserting testfile contents
- oid = '16265436'
- reading large object
Segmentation fault

Test case #4:
- same as #2 and #3 except
- postgresql-libs-7.3.4 PGDG used

$ perl test.pl
- reading testfile '/bin/ls'
- inserting testfile contents
- oid = '16265437'
- reading large object

... after ~32768 bytes, process loops reading the socket
read(3, 0x81cc938, 5) = -1 EAGAIN (Resource temporarily unavailable)
but doesn't appear to segfault (unless I am not patient enough)

This problem is a bastard as it makes getting data out of an
otherwise perfectly good database rather difficult. In other
words, its a show-stopper when migrating from 7.2 -> 7.3.

Regards,
Kevin

Attachment Content-Type Size
test.pl application/octet-stream 1.3 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-08-14 19:22:43 Re: "Bug" report - Serious (local shell)
Previous Message Stephan Szabo 2003-08-14 18:46:47 Re: "Bug" report - Serious (local shell)