[php-src] Issue #10672: pg_lo_open segfaults in the strict_types mode
| From: | morozov | Date: | Wed, 22 Feb 2023 22:48:24 +0000 |
| Subject: | [php-src] Issue #10672: pg_lo_open segfaults in the strict_types mode | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243788@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10672
Author: morozov
### Description
The following code:
```php
<?php
declare(strict_types=1);
$conn = pg_connect("host='127.0.0.1' dbname='postgres'
user='postgres' password='Passw0rd'");
if ($conn === false) {
die(pg_last_error());
}
// Begin a transaction
pg_query($conn, 'BEGIN');
// Create an empty large object
$oid = pg_lo_create($conn);
if ($oid === false) {
die(pg_last_error($conn));
}
// Open the large object for writing
$lob = pg_lo_open($conn, $oid, 'w');
if ($oid === false) {
die(pg_last_error($conn));
}
echo 'The large object has been opened successfully.', PHP_EOL;
```
Resulted in this output:
```
PHP Fatal error: Uncaught ValueError: Mode must be one of 'r', 'r+',
'w', or 'w+' in /Users/morozov/pgsql-bug.php:22
Stack trace:
#0 /Users/morozov/pgsql-bug.php(22): pg_lo_open(Object(PgSql\Connection), 16896, 'w')
#1 {main}
thrown in /Users/morozov/pgsql-bug.php on line 22
Fatal error: Uncaught ValueError: Mode must be one of 'r', 'r+', 'w',
or 'w+' in /Users/morozov/pgsql-bug.php:22
Stack trace:
#0 /Users/morozov/pgsql-bug.php(22): pg_lo_open(Object(PgSql\Connection), 16896, 'w')
#1 {main}
thrown in /Users/morozov/pgsql-bug.php on line 22
fish: Job 1, 'php pgsql-bug.php' terminated by signal SIGSEGV (Address boundary error)
```
But I expected this output instead:
```
The large object has been opened successfully.
```
Commenting out the
declare(strict_types=1); line addresses the issue.
### PHP Version
8.2.3
### Operating System
macOS Ventura 13.2.1