php / php/pecl-database-ibm_db2

SIGSEGV with PHP 8.5

Open
#67 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
26
Forks
27
PR merge metrics
No merged PRs in 30d

Description

SIGSEGV with PHP 8.5 on 2.3.0

backtrace


* thread #1, name = 'php', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x57b9d9c0)
  * frame #0: 0x00007fffedea6ea1 libodbc.so.2`SQLSetEnvAttr + 49
    frame #1: 0x00007fffede443f0 ibm_db2.so`_php_db2_connect_helper(execute_data=0x00007ffff4c173f0, return_value=0x00007ffff4c172e0, pconn_res=0x00007fffffffae58, isPersistent=0) at ibm_db2.c:2499:18
    frame #2: 0x00007fffede44bf3 ibm_db2.so`zif_db2_connect(execute_data=0x00007ffff4c173f0, return_value=0x00007ffff4c172e0) at ibm_db2.c:2870:14
    frame #3: 0x000055555604d7ec php`ZEND_DO_ICALL_SPEC_OBSERVER_HANDLER at zend_vm_execute.h:1487:2
    frame #4: 0x00005555560ced69 php`execute_ex(ex=0x00007ffff4c17020) at zend_vm_execute.h:115956:5
    frame #5: 0x00005555560d47a7 php`zend_execute(op_array=0x00007ffff4c83140, return_value=0x0000000000000000) at zend_vm_execute.h:121434:2
    frame #6: 0x0000555556178e52 php`zend_execute_script(type=8, retval=0x0000000000000000, file_handle=0x00007fffffffc650) at zend.c:1977:3
    frame #7: 0x0000555555f167c6 php`php_execute_script_ex(primary_file=0x00007fffffffc650, retval=0x0000000000000000) at main.c:2640:13
    frame #8: 0x0000555555f1694c php`php_execute_script(primary_file=0x00007fffffffc650) at main.c:2680:9
    frame #9: 0x000055555617b564 php`do_cli(argc=9, argv=0x0000555557753a60) at php_cli.c:951:5
    frame #10: 0x000055555617c5c8 php`main(argc=9, argv=0x0000555557753a60) at php_cli.c:1362:18
    frame #11: 0x00007ffff6b8ad90 libc.so.6`__libc_start_call_main(main=(php`main at php_cli.c:1190:1), argc=9, argv=0x00007fffffffda28) at libc_start_call_main.h:58:16
    frame #12: 0x00007ffff6b8ae40 libc.so.6`__libc_start_main_impl(main=(php`main at php_cli.c:1190:1), argc=9, argv=0x00007fffffffda28, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffda18) at libc-start.c:392:3

Frame 3:

Image

Frame2:

Image frame 3 Image

stack trace

Image

php script

$configuration = getEnvironmentConfiguration('IBM_DB2');
$host = $configuration['host'];
$port = $configuration['port'];
$user = $configuration['uid'];
$password = $configuration['pwd'];
$database = $configuration['database'];

    $conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
                   "HOSTNAME=$host;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
    $conn = db2_connect($conn_string, '', '');

    // Connection successful
    $stmt = db2_exec($conn, 'SELECT * FROM SYSCAT.REFERENCES');

    // Statement executed successfully
    $preparedStmt = db2_prepare($conn, 'SELECT * FROM SYSCAT.REFERENCES SC WHERE SC.TABNAME = ?');

    // Prepared statement created successfully
    db2_bind_param($preparedStmt, 1, "SYSCAT.REFERENCES", DB2_PARAM_IN);
    db2_execute($preparedStmt, array("SYSCAT.REFERENCES"));

    $ret = db2_exec($conn, 'SELECT * FROM SYSCAT.REFERENCES');
    var_dump($ret);
    db2_free_stmt($preparedStmt);

    // Close the statement
    db2_free_stmt($stmt);

    // Close the connection when done
    db2_close($conn);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied PHP connection script with PHP 8.5 and ibm_db2 2.3.0 to reproduce the crash, then inspect ibm_db2.c at lines 2499 and 2870 alongside the backtrace. Done means db2_connect no longer segfaults and the shown connection and statement operations complete successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.