Skip to content

Commit 9574d5f

Browse files
ondrejmirtesclaude
andcommitted
Pass the combinations() argument to the twin's helper as the zval it arrived in
Rewrapping the parsed table with ZVAL_ARR marked an immutable array refcounted — `[]` is the read-only zend_empty_array — and the call into IterableHelper::combinations() then addref'd read-only memory: a SIGBUS or SIGSEGV on `CombinationsHelper::combinations([])`, the first case of turbo-ext/tests/smoke.php, whenever opcache does not intern the literal. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Fdg8n3eEi4ZoXa4dA2k4A
1 parent ef16d6e commit 9574d5f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎turbo-ext/src/CombinationsHelper.cpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ void pt_register_combinations_helper()
118118
ptdecl::CombinationsHelper::declareProperties(cls);
119119

120120
cls.method("combinations", reg::PublicStatic, 1, { reg::arrayArg("arrays") }, [](INTERNAL_FUNCTION_PARAMETERS) {
121-
HashTable *arrays;
122-
if (!zp::parse<zp::Ht>(execute_data, arrays)) RETURN_THROWS();
123-
zval arraysZv;
124-
ZVAL_ARR(&arraysZv, arrays);
125-
zv::Val result = CombinationsHelper::combinations(&arraysZv);
121+
/* the argument zval as passed: rewrapping its table with ZVAL_ARR
122+
* would mark an immutable array ([] is zend_empty_array) refcounted,
123+
* and the call below would then addref read-only memory */
124+
zval *arrays;
125+
if (!zp::parse<zp::Arr>(execute_data, arrays)) RETURN_THROWS();
126+
zv::Val result = CombinationsHelper::combinations(arrays);
126127
if (UNEXPECTED(result.isUndef())) RETURN_THROWS();
127128
result.intoReturnValue(return_value);
128129
});

0 commit comments

Comments
 (0)