Skip to content

Segfault when connecting to fabric #1541

@hgiesenow

Description

@hgiesenow

Please check the FAQ (frequently-asked questions) first. If you have other questions or something to report, please address the following (skipping questions might delay our responses):

PHP version
8.1 up to 8.4 with docker (alpine or debian based)

PHP SQLSRV or PDO_SQLSRV version
pdo_sqlsrv 5.12.0

Microsoft ODBC Driver version
msodbcsql18_18.5.1.1-1_amd64

SQL Server version
MS Fabric

Client operating system
Linux (Docker)

Problem description
Following the instructions from https://learn.microsoft.com/en-us/sql/connect/php/azure-active-directory?view=sql-server-ver17#pdo_sqlsrv-driver-1 I just get a segfault.
The stacktrace looks like

Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex.S:79
#1  0x000056e65573f257 in zend_update_property_string ()
#2  0x00007efd950a50d9 in (anonymous namespace)::pdo_sqlsrv_throw_exception(sqlsrv_error const*) ()
   from /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_sqlsrv.so
#3  0x00007efd950a6730 in pdo_sqlsrv_handle_dbh_error(sqlsrv_context&, unsigned int, int, __va_list_tag (*) [1]) ()
   from /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_sqlsrv.so
#4  0x00007efd950a3790 in call_error_handler(sqlsrv_context*, unsigned long, int, ...) ()
   from /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_sqlsrv.so
#5  0x00007efd950ac41e in core_sqlsrv_connect(sqlsrv_context&, sqlsrv_context&, sqlsrv_conn* (*)(void*, bool (*)(sqlsrv_context&, unsigned int, int, __va_list_tag (*) [1]), void*), char const*, char const*, char const*, _zend_array*, bool (*)(sqlsrv_context&, unsigned int, int, __va_list_tag (*) [1]), connection_option const*, void*, char const*) () from /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_sqlsrv.so
#6  0x00007efd950a1a1d in pdo_sqlsrv_db_handle_factory(_pdo_dbh_t*, _zval_struct*) ()
--Type <RET> for more, q to quit, c to continue without paging-- 
   from /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_sqlsrv.so
#7  0x000056e6555b0207 in ?? ()
#8  0x000056e65579ff53 in execute_ex ()
#9  0x000056e6557a15ef in zend_execute ()
#10 0x000056e655733de8 in zend_execute_scripts ()
#11 0x000056e6556d0471 in php_execute_script ()
#12 0x000056e6558185a3 in ?? ()
#13 0x000056e6554451b6 in ?? ()
#14 0x00007efd97e1a24a in __libc_start_call_main (main=main@entry=0x56e655444e00, argc=argc@entry=2, argv=argv@entry=0x7ffc133b42a8)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#15 0x00007efd97e1a305 in __libc_start_main_impl (main=0x56e655444e00, argc=2, argv=0x7ffc133b42a8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7ffc133b4298) at ../csu/libc-start.c:360
--Type <RET> for more, q to quit, c to continue without paging--
#16 0x000056e6554464f1 in _start ()

on alpine based images it's a bit different

#0  0x000071be3d19345e in strlen (s=<optimized out>) at src/string/strlen.c:17
#1  0x00005c2ac6175c57 in zend_update_property_string ()

Repro code or steps to reproduce
Build a docker image with the libraries included

FROM php:8.4-bookworm
RUN curl -sSL -O https://packages.microsoft.com/config/debian/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2 | cut -d '.' -f 1)/packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN rm packages-microsoft-prod.deb
RUN apt update 
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev gdb

RUN pecl install pdo_sqlsrv sqlsrv
RUN docker-php-ext-enable pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv

Take the example from https://learn.microsoft.com/en-us/sql/connect/php/azure-active-directory?view=sql-server-ver17#pdo_sqlsrv-driver-1 and adjust only the server name to the SQL endpoint from fabric.

$adServer = 'xxx.datawarehouse.fabric.microsoft.com';

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions