UndefinedBehaviorSanitizer crash in SQLite3 BLOB fseek(PHP_INT_MIN, SEEK_END)
オープン
初心者向け
まだ誰も着手していません。
Bug
Category: Streams
Extension: sqlite3
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
$db = new SQLite3(':memory:');
$db->exec('CREATE TABLE test (id TEXT, data BLOB)');
$stmt = $db->prepare('INSERT INTO test (id, data) VALUES (:id, :data)');
$stmt->bindValue(':id', 'a', SQLITE3_TEXT);
$stmt->bindValue(':data', 'TEST TEST', SQLITE3_BLOB);
$stmt->execute();
$row = $db->querySingle("SELECT data FROM test WHERE id='a'", true);
$stream = $db->openBlob('test', 'data', 1);
var_dump(fseek($stream, PHP_INT_MIN, SEEK_END));
Resulted in this output:
php-src/ext/sqlite3/sqlite3.c:1193:47: runtime error: negation of -9223372036854775808 cannot be represented in type 'zend_off_t' (aka 'long long'); cast to an unsigned type to negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/arshid/Downloads/php-src/ext/sqlite3/sqlite3.c:1193:47
[2] 88129 abort sapi/cli/php z.php
But I expected this output instead:
int(-1)
PHP Version
PHP 8.4.11 (cli) (built: Jul 29 2025 15:30:21) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.11, Copyright (c) Zend Technologies
with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans
with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ext/sqlite3/sqlite3.c の 1193 行目から開始し、提供されている PHP スクリプトを使用して UndefinedBehaviorSanitizer の失敗を再現します。SEEK_END を指定した PHP_INT_MIN に対する fseek の処理を確認し、関連する SQLite3 ストリームテストを追加または更新して、呼び出しが未定義動作なしに完了し、-1 を返すようにします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php, sqlite
- 領域
- database
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 72/100