php5-pgsql crash on getting an error back from postgres

Bug #660227 reported by Matt Clarkson on 2010-10-13
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)

Bug Description

Binary package hint: php5

A connect failure in pg_connect() or an error in pg_query() will result in php exiting after printing a WARNING instead of continuing execution.

I have attached a test script that tries to connect to a non-existent DB - on Debian Lenny prints an error correctly:

$ php test.php
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: database "mary" does not exist in /home/mattc/test.php on line 3
Connection Failure

But on Maverick simply dies after the pg_connect() failure - note that "Connection Failure" is not printed:

$ php test.php
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: database "mary" does not exist
 in /home/mattc/test.php on line 3

This looks like a related upstream bug:

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: php5-pgsql 5.3.3-1ubuntu9
ProcVersionSignature: Ubuntu 2.6.35-22.33-generic
Uname: Linux 2.6.35-22-generic i686
NonfreeKernelModules: ksplice_r5fvn98f ksplice_vx7641xl ksplice_hy9n8rtk_vmlinux_new ksplice_hy9n8rtk ksplice_wwlcxuj6 ksplice_ndv79lmx_vmlinux_new ksplice_ndv79lmx ksplice_wqjhxpxk_vmlinux_new ksplice_wqjhxpxk ksplice_vxxnjbjc ksplice_aoojhvc5_vmlinux_new ksplice_aoojhvc5 ksplice_csiv07iy_vmlinux_new ksplice_csiv07iy nvidia
Architecture: i386
Date: Thu Oct 14 10:23:38 2010
 PATH=(custom, no user)
SourcePackage: php5

=== Stable Release Update (SRU) information ===


The patch being removed does not fix any reproducible problem, so it really should not have been added in the first place.


Natty is not open yet.


See associated merge proposal


The php script labeled "Test script" attached to this bug reproduces the problem exactly. If the string "Connection Failure" is not seen after running it, the bug is present.


If we did fix the pgsql segfaulting problem reported in

It will return. However, that bug was never actually confirmed by users, and so I think the potential is "VERY LOW"

Related branches

Matt Clarkson (drmattoclarkson) wrote :
tags: added: regression-release
Clint Byrum (clint-fewbar) wrote :

I've tried the test.php script on maverick and it definitely exits abruptly where one would not expect it to.

Marking Confirmed, setting Importance to High, as I believe this may affect all php5-pgsql users in a very negative way (errors should not crash your PHP!)

Changed in php5 (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Clint Byrum (clint-fewbar) wrote :

Also, I suspect I may have introduced this regression in this bug fix:

Changed in php5 (Ubuntu):
assignee: nobody → Clint Byrum (clint-fewbar)
status: Confirmed → In Progress
description: updated
Clint Byrum (clint-fewbar) wrote :

Ok, this is fixed by removing the patch added in bug #607646

Merge proposal has the diff. I've tested building on i386 (via ppa) and amd64, both cases produce the expected output.

Martin Pitt (pitti) wrote :

I asked for confirmation in bug 607646 as well.

Changed in php5 (Ubuntu Maverick):
status: New → Fix Committed
tags: added: verification-needed

Accepted php5 into maverick-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See for documentation how to enable and use -proposed. Thank you in advance!

Clint Byrum (clint-fewbar) wrote :

I verified that the fix is good on a clean maverick i386 install with only php5 added from proposed:

clint@maverick-mini-32:~$ fgrep Package: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_maverick-proposed_*_Packages|cut -d' ' -f2|xargs dpkg -l 2>&1|grep -v '^No' |grep '^ii'
ii libc-bin 2.12.1-0ubuntu6 Embedded GNU C Library: Binaries
ii libc6 2.12.1-0ubuntu6 Embedded GNU C Library: Shared libraries
ii libdrm-intel1 2.4.21-1ubuntu2 Userspace interface to intel-specific kernel DRM services -- runtime
ii libdrm-nouveau1 2.4.21-1ubuntu2 Userspace interface to nouveau-specific kernel DRM services -- runtime
ii libdrm-radeon1 2.4.21-1ubuntu2 Userspace interface to radeon-specific kernel DRM services -- runtime
ii libdrm2 2.4.21-1ubuntu2 Userspace interface to kernel DRM services -- runtime
ii libldap-2.4-2 2.4.23-0ubuntu3 OpenLDAP libraries
ii libudev0 162-2 udev library
ii linux-headers-2.6.35-22 2.6.35-22.34 Header files related to Linux kernel version 2.6.35
ii linux-headers-2.6.35-22-generic 2.6.35-22.34 Linux kernel headers for version 2.6.35 on x86/x86_64
ii linux-image-2.6.35-22-generic 2.6.35-22.34 Linux kernel image for version 2.6.35 on x86/x86_64
ii php5-cli 5.3.3-1ubuntu9.1 command-line interpreter for the php5 scripting language
ii php5-common 5.3.3-1ubuntu9.1 Common files for packages built from the php5 source
ii php5-pgsql 5.3.3-1ubuntu9.1 PostgreSQL module for php5
ii tzdata 2010m-0ubuntu0.10.10 time zone and daylight-saving time data
ii udev 162-2 rule-based device node and kernel event manager
clint@maverick-mini-32:~$ php test.php
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? in /home/clint/test.php on line 3
Connection Failure

tags: added: verification-done
removed: verification-needed
JamesL (jamesly0n) wrote :

Yep, the proposed package has no problems for me (x84-64, either a clean virtual machine install or my laptop).

Matt Clarkson (drmattoclarkson) wrote :

I can confirm that the updated package in maverick-proposed fixes this problem for me.

seorc (seorc) wrote :

I had the same problem in maverick for i386: blank response from the server on bad pg_connect() or pg_query() execution. By the way, the same happened when calling pg_last_error(), even when there were no connection or query errors at all. The proposed package solved the problem.

Martin Pitt (pitti) wrote :

Copied to natty as well.

Changed in php5 (Ubuntu):
status: In Progress → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package php5 - 5.3.3-1ubuntu9.1

php5 (5.3.3-1ubuntu9.1) maverick-proposed; urgency=low

  * debian/patches/php52389-pgsql-segfault.patch: removing,
    causes error handling to fail (LP: #660227)
 -- Clint Byrum <email address hidden> Thu, 14 Oct 2010 06:46:02 -0700

Changed in php5 (Ubuntu Maverick):
status: Fix Committed → Fix Released
Changed in php5 (Ubuntu):
assignee: Clint Byrum (clint-fewbar) → nobody
tags: added: testcase
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers