php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32537 Segmentation faults and random errors with PostgreSQL 8 and persistence
Submitted: 2005-04-01 18:27 UTC Modified: 2005-04-27 18:07 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mauroi at digbang dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mauroi at digbang dot com
New email:
PHP Version: OS:

 

 [2005-04-01 18:27 UTC] mauroi at digbang dot com
Description:
------------
Out application works perfectly using normal postgresql connections. But when we enable persistence we're getting random errors and segmentation faults.
We're using PHP 5 and PostgreSQL 8.0.1 .
The sequence of querys is something like 
BEGIN;
SELECT;
INSERT;
.....
COMMIT;
BEGIN;
ROLLBACK;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-01 18:29 UTC] derick@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2005-04-02 02:04 UTC] mauroi at digbang dot com
The following class (code) causes a segmentation fault if it has the ROLLBACK query in the destructor.
It results in a segfault always if it's executed as a command line script, and sometimes if it's called by a web request (lots of calls repeteadly and with persistence).
The extension code (pgsql.c) has a "feature" which automatically close every query result that was left opened. But I think that it's pretty acceptable to have a script like this one.
<?
class db
{
        public function __construct($string)
        {
                $this->handle = pg_pconnect($string);
                $this->Execute('BEGIN');
        }

        public function Commit()
        {
                $this->execute('COMMIT');
                $this->execute('BEGIN');
        }

        public function Execute($query)
        {
                $res = pg_query($this->handle, $query);
                pg_affected_rows($res);
                pg_free_result($res);
        }

        public function __destruct()
        {
                $this->execute('ROLLBACK');
                pg_close($this->handle);
        }

        private $handle;
}

$c = new db([connection string]);
$c->execute("SELECT 1");
$c->Commit();
?>
 [2005-04-03 03:24 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip


 [2005-04-05 00:03 UTC] mauroi at digbang dot com
same result...
 [2005-04-05 00:08 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2005-04-12 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-04-23 16:16 UTC] edvin at kkg dot lt
Same problem under php 5.0.4 and postgres 8.0.2.
Sample code,who causes segfault:

class db
{
function connect(){
$this->db = pg_connect($this->conn);
 if (!$this->db) {
	$this->ErrorMsg('cannot connect to db');
	}
}

function ErrorMsg($ErrDescription)
	{
		$this->sql("ROLLBACK"); /* if this line commented,all going OK */
		$this->disconnect();
		die("Error<br>$ErrDescription");
	}
}
 [2005-04-27 18:07 UTC] mauroi at digbang dot com
Sorry for the lack of feedback. Since the bug can be ommited by removing the rollback statement from the destructor, i don't have the time to do further tests.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 01:01:30 2024 UTC