[php-src] Issue #20964: UBSAN: fseek() on php://memory with PHP_INT_MIN causes undefined behavior

From: Date: Sun, 18 Jan 2026 03:55:18 +0000
Subject: [php-src] Issue #20964: UBSAN: fseek() on php://memory with PHP_INT_MIN causes undefined behavior
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251560@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20964 Author: arshidkv12 ### Description The following code: ```php <?php $stream = fopen('php://memory', 'r+'); $result = fseek($stream, PHP_INT_MIN, SEEK_END); var_dump($result);``` Resulted in this output: ``` /Users/arshid/Downloads/php-src/main/streams/memory.c:168:45: 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/main/streams/memory.c:168:45 [4] 93646 abort sapi/cli/php z.php ``` But I expected this output instead: ``` -1 ``` ### PHP Version ```plain PHP 8.6.0-dev (cli) (built: Jan 18 2026 08:54:52) (NTS DEBUG) Copyright (c) The PHP Group Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies ``` ### Operating System _No response_

« previous php.bugs (#251560) next »