-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add integration tests #294
Conversation
…21-feat-integration-tests
Don't have a mac os machine so can't easily debug the mac os failures, would be really happy if someone could give a try... |
I am able to reproduce this on PHP 8.0 with macos, but only the debug build of I dug pretty deep bit didn't get a definitive answer. It seems PHP is not able to retrieve the classname of the return type of the function. I verified the [src/zend/_type.rs:83] ptr_ = 0x000000013960acb0
[src/zend/_type.rs:85] &*(ptr_ as *mut ZendStr) = Ok(
"TestClass",
)
[src/builders/function.rs:151] &args = [
_zend_internal_arg_info {
name: 0x0000000000000000,
type_: zend_type {
ptr: 0x000000013960acb0,
type_mask: 8388608,
},
default_value: 0x0000000000000000,
},
] The "extra" ArgInfo for a function which contains the return type is good. The I can see when the function is called, the [tests/src/lib.rs:143] args = _zend_arg_info {
name: 0x0000000000000000,
type_: zend_type {
ptr: 0x0000000141e0bfc0,
type_mask: 8388608,
},
default_value: 0x0000000000000000,
}
The ptr for type_.ptr:
[tests/src/lib.rs:142] &*(args.type_.ptr as *const ZendStr) = Ok(
"\u{1}",
) I'm not sure if this is the right rabbit hole to be going down. I don't see anything that should make the debug build fail, it could be that the ZendStr is somehow getting freed, perhaps the debug build is changing the memory behaviour. |
Oh so the mac os shivammathur php build is actually a debug build, that could actually explain some of the (unrelated, but similarly occurring due to memory corruption) failures I was getting locally with a Linux debug build, unreproducible in the CI.... Might be worth using a debug build for all CI tasks. |
Oh I see why it's only being triggered on the Debug build, it seems this check is only made for internal functions if ZEND_EDBUG: #if ZEND_DEBUG
static ZEND_COLD void zend_verify_internal_return_error(const zend_function *zf, zval *value)
{
...
static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, const char *returned_msg, const char *returned_kind)
{
...
}
static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
{
...
}
#endif |
Yeah I'd imagine we should be running all the test envs with a debug build in that case. i think you may be able to reproduce if run you against a debug build on linux? |
FYI we are setting the PHP build to debug on macos here: https://github.com/davidcole1340/ext-php-rs/blob/master/.github/workflows/build.yml#L48 |
Indeed, I encountered the exact same issue previously on a linux debug build precisely due to that type check for return types, which lead to the discovery of a bug in ZendType (a simple C string was used instead of a zend string for the type name), which I fixed in 86c9074, but then the same issue started occurring again here, only on Mac OS builds, and not on a local Linux debug build (which has different issues, namely #290 + a segfault when running library tests probably due to memory corruption as for #290).
Actually shouldn't that enable debug builds for all OSes? |
Hmm ok I think 86c9074#diff-758fcaf4f7ca5c65a01fb257423dc04af5d266f93547a89f2559bec5410b2f1aL85 might be the key. To also test this I can do: $r = new ReflectionFunction('test_class');
var_dump( $r->getReturnType()->getName() ); That gives me string(9) "TestClass" |
The issue was caused by the fact that php 8.2 and below want a C string in the arginfo to then convert it internally to a zend string, but php 8.3 wants a C string only if the literal flag is set, and a zend string otherwise. |
Reverts #293