#32537 [Com]: Segmentation faults and random errors with PostgreSQL 8 and persistence

From: Date: Sat, 23 Apr 2005 14:16:48 +0000
Subject: #32537 [Com]: Segmentation faults and random errors with PostgreSQL 8 and persistence
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78076@lists.php.net to get a copy of this message
 ID:               32537
 Comment by:       edvin at kkg dot lt
 Reported By:      mauroi at digbang dot com
 Status:           No Feedback
 Bug Type:         PostgreSQL related
 Operating System: Linux
 PHP Version:      5.0.3
 New Comment:

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");
	}
}


Previous Comments:
------------------------------------------------------------------------

[2005-04-12 01:00:06] 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-05 00:08:15] 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-05 00:03:19] mauroi at digbang dot com

same result...

------------------------------------------------------------------------

[2005-04-03 03:24:16] 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-02 02:04:05] 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();
?>

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/32537

-- 
Edit this bug report at http://bugs.php.net/?id=32537&edit=1


Thread (9 messages)

« previous php.bugs (#78076) next »