-
Notifications
You must be signed in to change notification settings - Fork 341
Description
I'm developing a PHP extension which overrides zend_execute_*
to fetch some values from the runtime. Whenever I need to dump a value I wrap it into a Php::Value
object then I switch over value.type()
to properly format it. The idea is that when I find an array I want to recursively call the format function with each member. Here's the relevant part:
switch (value.type()) {
// ...
case Php::Type::Array:
case Php::Type::ConstantArray:
for (auto &it : value) {
output_string(it.first.stringValue().c_str());
format(it.second);
}
break;
// ...
}
Now this works against simple test cases but when I run complex PHP code, weird things happen. Scripts complain about wrong values (e.g., NULL or unexpected types), even if the iteration body is empty. This suggests that zvalues may be corrupted during the mere iteration phase.
After some debugging I noticed that the problem seems to be related to how the current value is stored or to what happens when the wrapping Php::Value
is destroyed. Any thoughts?
I apologize if I'm not providing any code to reproduce the issue but I didn't find a simple way.