-
Notifications
You must be signed in to change notification settings - Fork 47
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
test_protocols intermittent failure #17
Comments
This issue is still present, and seems to fail unconditionally now instead of only intermittently (BigSur, M1). I suspect that this is a bug in how PyObjC builds formal protocols. |
The weird thing is that the "fake" implementation for Some more checking: Added sanity check with Registering all protocol selectors twice seems to fix the issue, but then those selectors end up twice in the protocol which causes other test failures. This seems to be an ObjC runtime bug, although I haven't been able yet to reproduce it outside of PyObjC... #import <objc/runtime.h>
#include <stdio.h>
int main(void)
{
SEL sel1 = sel_registerName("protoMethod:");
const char* sig1 = "I@:";
SEL sel2 = sel_registerName("anotherProto:with:");
const char* sig2 = "v@:ii";
Protocol* p = objc_allocateProtocol("MyProtocol");
struct objc_method_description descr;
if (p == NULL) {
printf("cannot create protocol\n");
return 1;
}
protocol_addMethodDescription(p, sel1, sig1, YES, YES);
descr = protocol_getMethodDescription(p, sel1, YES, YES);
if (descr.name == NULL) {
printf("added selector 1 not found protocol (build phase)\n");
return 1;
}
protocol_addMethodDescription(p, sel2, sig2, YES, YES);
descr = protocol_getMethodDescription(p, sel2, YES, YES);
if (descr.name == NULL) {
printf("added selector 2 not found protocol (build phase)\n");
return 1;
}
objc_registerProtocol(p);
descr = protocol_getMethodDescription(p, sel1, YES, YES);
if (descr.name == NULL) {
printf("added selector 1 not found protocol (registered phase)\n");
return 1;
}
descr = protocol_getMethodDescription(p, sel2, YES, YES);
if (descr.name == NULL) {
printf("added selector 2 not found protocol (registered phase)\n");
return 1;
}
return 0;
} That's it for now, although I might return to this issue later on. |
That's not true, the problem with NSXPCInterface is different, see #256. |
I filed FB11984735 with apple about this. The program below fails consistently for me, with two methods it only fails intermittently. Removing the strdup calls appears to fix the issue #import <objc/runtime.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
char* selname1 = strdup("protoMethod:");
char* selname2 = strdup("anotherProto:with:");
char* selname3 = strdup("yetAnotherProto:with:");
SEL sel1 = sel_registerName(selname1);
const char* sig1 = strdup("I@:");
SEL sel2 = sel_registerName(selname2);
const char* sig2 = strdup("v@:ii");
//assert(sig2!=NULL);
SEL sel3 = sel_registerName(selname3);
const char* sig3 = strdup("v@:@@");
Protocol* p = objc_allocateProtocol("MyProtocol");
struct objc_method_description descr;
if (p == NULL) {
printf("cannot create protocol\n");
return 1;
}
protocol_addMethodDescription(p, sel1, sig1, YES, YES);
descr = protocol_getMethodDescription(p, sel1, YES, YES);
if (descr.name == NULL) {
printf("added selector 1 not found protocol (build phase)\n");
return 1;
}
protocol_addMethodDescription(p, sel2, sig2, YES, YES);
descr = protocol_getMethodDescription(p, sel2, YES, YES);
if (descr.name == NULL) {
printf("added selector 2 not found protocol (build phase)\n");
return 1;
}
protocol_addMethodDescription(p, sel3, sig3, YES, YES);
descr = protocol_getMethodDescription(p, sel3, YES, YES);
if (descr.name == NULL) {
printf("added selector 3 not found protocol (build phase)\n");
return 1;
}
objc_registerProtocol(p);
descr = protocol_getMethodDescription(p, sel1, YES, YES);
if (descr.name == NULL) {
printf("added selector 1 not found protocol (registered phase)\n");
return 1;
}
descr = protocol_getMethodDescription(p, sel2, YES, YES);
if (descr.name == NULL) {
printf("added selector 2 not found protocol (registered phase)\n");
return 1;
}
descr = protocol_getMethodDescription(p, sel3, YES, YES);
if (descr.name == NULL) {
printf("added selector 3 not found protocol (registered phase)\n");
return 1;
}
return 0;
} |
Developer forum post about this: https://developer.apple.com/forums/thread/724655 (at the time of this message this post is "in review"). |
Original report by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).
test_protocol fails intermittently on OSX 10.8, reason unknown.
To reproduce:
Edit Modules/objc/objc-runtime-compat.h and disable the #define for
protocol_getMethodDescription
Build and install
Run PyObjCTest/test_protocol.py a number of times
On my machine this fails at least once in 10 runs of the tests.
As a workaround I've added a wrapper for protocol_getMethodDescription to the
runtime compatibility file. That workaround is almost certainly the wrong solution though, hence this tracker item.
The text was updated successfully, but these errors were encountered: