Skip to content

Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland #10908

Closed
@rvk01

Description

@rvk01

Description

With a simple apt-get upgrade on my RPI 4 it was upgraded to a 64 bit kernel automatically :(
uname -a
Linux space01 6.1.19-v8+ #1637 SMP PREEMPT Tue Mar 14 11:11:47 GMT 2023 aarch64 GNU/Linux

Now the SELECT of a BIGINT and NUMERIC(18,3) always results in a "Bus error".

Switching back to the 32 bit kernel (with arm_64bit=0 in /boot/config.txt) it works again:
uname -a
Linux space01 6.1.19-v7l+ #1637 SMP Tue Mar 14 11:07:55 GMT 2023 armv7l

But I can't use the 32 bit kernel anymore because of multiple out of memory errors.
(with 8GB there is too little space in the lower memory)

Casting a BIGINT to INTEGER and a NUMERIC(18,3) to NUMERIC(9,3) works too.
(It seems from NUMERIC(10,3) and above the error occurs again.)

Reproduce with the following code (command for creating testdatabase is in the comments):

<?php

// Environment Raspberry Pi 4 8GB / Raspbian GNU/Linux 11 (bullseye)

// PHP 8.2.4 with PDO
// php8.2-common    8.2.4-1+0~20230316.17+debian11~1.gbp556b04
// php8.2-interbase 8.2.4-1+0~20230316.17+debian11~1.gbp556b04
// Firebird client LI-V6.3.7.33374 Firebird 3.0

// Working in kernel 32 bit: Linux space01 6.1.19-v7l+ #1637 SMP Tue Mar 14 11:07:55 GMT 2023 armv7l
// Not working in kernel 64 bit: Linux space01 6.1.19-v8+ #1637 SMP PREEMPT Tue Mar 14 11:11:47 GMT 2023 aarch64 GNU/Linux

/*
Create the test database on a console terminal (maybe adjust the path of the database):

isql-fb <<EOF
CREATE DATABASE 'localhost:/home/firebird/testdb.fdb' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 8192;
COMMIT;
CONNECT 'localhost:/home/firebird/testdb.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
CREATE TABLE TESTTABLE(
  ID BIGINT NOT NULL,
  CODE VARCHAR(60) NOT NULL,
  NUM NUMERIC(18, 3)
);
INSERT INTO TESTTABLE VALUES(1, 'ABC', 12.34);
COMMIT;
exit;
EOF

*/

$fb = new PDO("firebird:dbname=localhost:/home/firebird/testdb.fdb;charset=utf8", 'SYSDBA', 'masterkey');

// the following sql gives the results (in the comments)

$sql="SELECT CODE FROM TESTTABLE"; // works fine
$sql="SELECT ID   FROM TESTTABLE"; // Bus error
$sql="SELECT NUM  FROM TESTTABLE"; // Bus error
$sql="SELECT *    FROM TESTTABLE"; // Bus error

$sql="SELECT CAST(NUM AS NUMERIC(9, 3)) FROM TESTTABLE"; // works fine
$sql="SELECT CAST(ID AS INTEGER)        FROM TESTTABLE"; // works fine
$sql="SELECT CAST(ID AS BIGINT)         FROM TESTTABLE"; // Bus error

foreach ($fb->query($sql) as $row) {
  print_r($row);
  print("\n");
}

Resulted in this output:

Bus error

But I expected this output instead:

Array
(
    [CAST] => 1
    [0] => 1
)

PHP Version

PHP 8.2.4

Operating System

Raspbian GNU/Linux 11 (bullseye)

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