Skip to content

Stdlib: memory_get_usage/peak(null) TypeError under strict_types (#30346) - #30365

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-30346-memory-get-usage-null-strict
Aug 11, 2026
Merged

Stdlib: memory_get_usage/peak(null) TypeError under strict_types (#30346)#30365
PurHur merged 1 commit into
masterfrom
agent/stdlib-30346-memory-get-usage-null-strict

Conversation

@PurHur

@PurHur PurHur commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Honor caller strict_types for memory_get_usage() / memory_get_peak_usage() $real_usage (Z_PARAM_BOOL) so literal/runtime null throws Zend-matching TypeError instead of soft DEP+int.
  • VM: frame-aware VmMath::parseBoolBuiltinArgForFrame after MemoryUsage enum handling (ext/standard/VmMemory.php).
  • JIT/AOT: compile-time null catchable abort + JitBoolArg::lowerCoerceZParamBool for soft null (lib/JIT/JitMemoryUsageArg.php).
  • Soft path unchanged: DEP + coerce to false / int usage (existing #21615 case).
  • php-src: ext/standard/basic_functions.c / .stub.phpmemory_get_usage(bool $real_usage = false): int.

Closes #30346

Test plan

  • VM repro: php bin/vm.php test/repro/issue_30346_memory_get_usage_null_strict.php
  • AOT repro: ./phpc build -o /tmp/mgu_null_strict test/repro/issue_30346_memory_get_usage_null_strict.php && /tmp/mgu_null_strict
  • Soft null still DEP+OK / AOT int: issue_21615_memory_usage_null.php + soft AOT one-liner
  • vendor/bin/phpunit -c phpunit.xml.dist --filter MemoryGetUsageNullStrict (VM+JIT compliance + unit)
  • Soft path + MemoryUsage bool handlers still green

Verification transcript (Docker php-compiler:22.04-dev)

===VM===
memory_get_usage(): Argument #1 ($real_usage) must be of type bool, null given
memory_get_peak_usage(): Argument #1 ($real_usage) must be of type bool, null given
===AOT===
… AOT_OK (same TypeError lines)
===PHPUnit MemoryGetUsageNullStrict===
OK (5 tests, 12 assertions)

Pillar probe before claim: north-star5-fast ok; helper-runtime-prelink red on stale DOM helpers (pre-existing, unrelated); inventory construct-flag doc drift only.

Made with Cursor

)

Honor caller strict_types for Z_PARAM_BOOL $real_usage via frame-aware
VmMath bool parse (and JIT lowerCoerceZParamBool), matching php-src.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 56532dc into master Aug 11, 2026
1 check failed
@PurHur
PurHur deleted the agent/stdlib-30346-memory-get-usage-null-strict branch August 11, 2026 20:11
PurHur added a commit that referenced this pull request Aug 11, 2026
…0371)

Re-emit and publish the x86_64-linux helper-runtime corpus so
check-helper-runtime-prelink --strict reports 0 stale (Pillar 1).
Also refresh SocketAtmark/SocketCreate/Memory units that went
stale on rebase onto master (#30365#30369).

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: memory_get_usage(null) under strict_types Deprecated+int — Zend TypeError (ext/standard/basic_functions.c)

1 participant