Skip to content

Regression: sem_get() auto_release — rejects int coerce and bool (re-#3704, ext/sysvsem/sysvsem.c) #19515

Closed

Description

@PurHur

Category

stdlib · php-src-strict / regression

Problem

After #3704 landed, sem_get() exists but argument #4 ($auto_release) does not match php-src. Zend types it as bool and coerces int (e.g. 1). This compiler’s execute path parses it as int (SemArgs::parseOptionalInt) while an earlier signature check expects bool — so neither 1 nor true works.

Repro Zend 8.2+ (2026-07-16) VM (2026-07-16, 787eb447a)
sem_get($key, 1, 0666, 1) SysvSemaphore object TypeError: … must be of type bool, int given
sem_get($key, 1, 0666, true) SysvSemaphore object TypeError: … must be of type int, bool given
ReflectionFunction('sem_get') param 4 bool int

php-src reference

PHP implementation target

  • ext/sysvsem/sem_get.php — use bool parsing with php-src coercion (int → bool), not parseOptionalInt for arg 4
  • ext/sysvsem/SemArgs.php — coerce-to-bool helper aligned with other builtins; PHP-in-PHP only (no runtime/*.c)
  • Align reflected parameter type/name with the stub (permissions, auto_release: bool)

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/sem.php <<'"'"'PHP'"'"'
<?php
$key = ftok(__FILE__, "s");
$a = @sem_get($key, 1, 0666, 1);
echo "int_arg=", ($a !== false ? "ok" : "fail"), "\n";
$b = @sem_get($key + 1, 1, 0666, true);
echo "bool_arg=", ($b !== false ? "ok" : "fail"), "\n";
PHP
php /tmp/sem.php; php bin/vm.php /tmp/sem.php'

Done when

  • Both auto_release=1 and auto_release=true return a live SysvSemaphore like Zend
  • ReflectionFunction('sem_get') shows bool $auto_release
  • Compliance .phpt under test/compliance/cases/sysvsem/
  • php-src-strict; no new C runtime logic

Activity

  1. added
    bugSomething isn't working
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 16, 2026
  2. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — starting this run

    Pillar 1 preflight (this host): docker_ok; release-readiness user_release_ready: yes (inventory 5082/5082, spine OK, north-star5-fast OK, vm-driver-probe OK). Claiming Lane A regression #19515 (ext/sysvsem — not STD Lib ext/standard-only / not Ext automation lists).

  3. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    Merged via #19523

    Verification

    • Issue repro: VM and Zend both return SysvSemaphore for auto_release=1 and auto_release=true (including $key + 1); reflection shows permissions / bool $auto_release.
    • vendor/bin/phpunit --filter SysvSemBuiltinTest — OK (2 tests), including sem_get_auto_release_bool.phpt.

    Pillar 1 preflight this run: user_release_ready: yes (inventory/spine/north-star5-fast/vm-driver-probe OK).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions