Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seg Fault when used with php8.2 or php8.3's pdo-odbc module & SSL #2

Open
AntoineGS opened this issue Sep 16, 2024 · 2 comments
Open

Comments

@AntoineGS
Copy link

I set up my certificates as described here:
https://docwiki.embarcadero.com/InterBase/2020/en/Setup_OTW/SSL_and_InterBase#Requesting_a_key

It has been running fine under PHP8.1 but our attempts to upgrade to 8.2 this morning resulted in segfaults when the PDO object is instantiated.

Connection string passed to PDO with 8.2:
odbc:Driver=InterBase;Dbname=XX.XX.XX.XX/4315?ssl=true?serverPublicFile=/opt/interbase/ibservercafile.pem??:C:\PATH\TO\DB.GDB;User=SYSDBA;Password=PASSWORD;Role=;CharacterSet=NONE;ReadOnly=Yes;NoWait=Yes;Dialect=1;QuotedIdentifier=Yes;SensitiveIdentifier=No;AutoQuotedIdentifier=No

With the following connection string without SSL it work though:
odbc:Driver=InterBase;Dbname=XX.XX.XX.XX/3050:C:\PATH\TO\DB.GDB;User=SYSDBA;Password=PASSWORD;Role=;CharacterSet=NONE;ReadOnly=Yes;NoWait=Yes;Dialect=1;QuotedIdentifier=Yes;SensitiveIdentifier=No;AutoQuotedIdentifier=No

Version:

  • Ubuntu 22.04.4 (same issue with 22.04.5)
  • PHP 8.2.23 (same issue with 8.3.11)
  • php8.2-odbc v8.2.23-1 (same issue with 8.3.11-1)
  • Interbase driver from the IB 2020 Update 6 Installer
  • unixodbc 2.3.9-5

Please let me know if you need more information.

@AntoineGS
Copy link
Author

AntoineGS commented Oct 30, 2024

Adding more information as I recently encountered this issue while transitioning a project to a docker container.
However, it now returns a Seg Fault with PHP 8.1.30, which I tested with Ubuntu 22.04.5 and 24.04.1.
In this particular case, I was able to track down the seg fault to libgds32.so, though I am not 100% sure it is the same issue, but it likely is:

image

The content of the php file:

<?php

$dbname = XX.XX.XX.XX/4315?ssl=true?serverPublicFile=/opt/interbase/ibservercafile.pem??:C:\Multidev\Gdbcreation\SV1020_012HO_LAB.GBB';

$connection_string = "odbc:Driver=InterBase;".
                "Dbname=".$dbname.";".
                "User=SYSDBA;".
                "Password=masterkey;".
                "Role=;".
                "CharacterSet=NONE;".
                "ReadOnly=No;".
                "NoWait=Yes;".
                "Dialect=1;".
                "QuotedIdentifier=Yes;".
                "SensitiveIdentifier=No;".
                "AutoQuotedIdentifier=No";
print_r('1' . PHP_EOL);
$dbh = new PDO($connection_string); \\ crashes here
print_r('2' . PHP_EOL);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print_r('3' . PHP_EOL);
$dbs = $dbh->prepare("select * from databaseid");
print_r('4' . PHP_EOL);
$result = $dbs->execute();
print_r('5' . PHP_EOL);
print_r($result);

The pem file exists:
image

The same test works with UnixODBC with the following config file:

[IB]
Description = InterBase ODBC driver
Driver = InterBase
Dbname = XX.XX.XX.XX/4315?ssl=true?serverPublicFile=/opt/interbase/ibservercafile.pem??:C:\Multidev\Gdbcreation\SV1020_012HO_LAB.GBB
Client =
User = SYSDBA
Password = masterkey
Role =
CharacterSet = NONE
ReadOnly = No
NoWait = No
Dialect = 1
QuotedIdentifier = Yes
SensitiveIdentifier = No
AutoQuotedIdentifier = No

@AntoineGS
Copy link
Author

Here is the Dockerfile and related files to create a container that replicates this problem.
Some files look redundant but this is a trimmed down version of an actual Dockerfile used.

In the root of the folder:

FROM ubuntu:24.04 AS ubuntu
LABEL authors="multidev"

ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /var/www/html
RUN apt update && apt install -y software-properties-common
RUN add-apt-repository ppa:ondrej/php
RUN add-apt-repository ppa:ondrej/apache2
RUN apt install -y \
    zip \
    libzip-dev \
    supervisor \
    nano \
    htop \
    wget \
    unixodbc \
    odbcinst \
    unixodbc-dev \
    libbz2-dev \
    curl \
    libcurl4-openssl-dev \
    libpng-dev \
    libicu-dev \
    libonig-dev \
    libedit-dev \
    libreadline-dev \
    libxml2-dev \
    libxslt1-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libmcrypt-dev \
    libssl-dev \
    libsqlite3-dev \
    fontconfig \
    neovim  \
    apache2 \
    apache2-utils

RUN apt install -y \
    php8.1 \
    php8.1-bcmath \
    php8.1-bz2 \
    php8.1-cli \
    php8.1-common \
    php8.1-curl \
    php8.1-gd \
    php8.1-intl \
    php8.1-mbstring \
    php8.1-mysql \
    php8.1-readline \
    php8.1-soap \
    php8.1-sqlite3 \
    php8.1-xml \
    php8.1-zip \
    php8.1-odbc

COPY . .

# Interbase Install
RUN wget https://altd.embarcadero.com/download/interbase/2020/Update6/InterBase_2020_Linux.zip
RUN unzip InterBase_2020_Linux.zip -d ./Interbase
RUN cd ./Interbase && \
    chmod +x ./install_linux_x86_64.sh && \
    ./install_linux_x86_64.sh -f ../src/php-interbase/deps/client_values.txt || true
RUN rm -r Interbase
RUN rm InterBase_2020_Linux.zip
RUN ln -s /usr/lib64/libgds.so /usr/lib/libgds.so || true

RUN rm /usr/local/bin/docker-entrypoint || true
RUN mv docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN mv docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# ODBC Install
RUN mkdir ./src/php-interbase/deps/odbc
RUN tar -xvf ./src/php-interbase/deps/OdbcIB-1.0.0.107.tar.gz -C ./src/php-interbase/deps/odbc
RUN cd ./src/php-interbase/deps/odbc/ && ./install.sh || true 
RUN rm -r ./src/php-interbase/deps/odbc
RUN mv docker/odbcinst.ini /etc/odbcinst.ini

EXPOSE 80
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/usr/bin/supervisord"]

The referred docker/docker-entrypoint.sh:

#!/bin/sh
exec "$@"

docker/odbcinst.ini:

[InterBase]
Description = InterBase ODBC driver
Driver = /usr/lib/libOdbcIB.so
UsageCount = 1

docker/supervisor.conf:

[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0

You will also need the following file for it to work which is your internal packaged version of this project:
src/php-interbase/deps/OdbcIB-1.0.0.107.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant