WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
UNCONFIRMED
122501
Dynamically generated JSExport protocols added to a class results in a crash
https://bugs.webkit.org/show_bug.cgi?id=122501
Summary
Dynamically generated JSExport protocols added to a class results in a crash
Axel Katerbau
Reported
2013-10-08 02:21:52 PDT
While the JSExport subprotocol method for exposing methods to JSC works fine when written in Code (as in the examples in Apple's docs), programmatically at runtime generated and added such protocols crash the JSC cocoa bridge. Run this code to see the crash (I use Xcode 5 release with iOS7 SDK). @import JavaScriptCore; @import ObjectiveC; int main(int argc, char * argv[]) { @autoreleasepool { JSContext *context = [[JSContext alloc] init]; Protocol *dynProtocol = objc_allocateProtocol("NSStringJSExport"); Protocol *jsExportProtocol = @protocol(JSExport); protocol_addProtocol(dynProtocol, jsExportProtocol); Method method = class_getInstanceMethod([NSString class], @selector(boolValue)); protocol_addMethodDescription(dynProtocol, @selector(boolValue), method_getTypeEncoding(method), YES, YES); // protocol_addMethodDescription(dynProtocol, @selector(boolValue), "@:", YES, YES); // <-- also crashes // protocol_addMethodDescription(dynProtocol, @selector(boolValue), "B@:", YES, YES); // <-- also crashes objc_registerProtocol(dynProtocol); class_addProtocol([NSString class], dynProtocol); context[@"NSString"] = [NSString class]; // <-- crashes here in parseObjCType context[@"myString"] = @"YES"; JSValue *value = [context evaluateScript:@"myResult = myString.boolValue()"]; NSLog(@"Result = %@", value); } }
Attachments
Corresponding Xcode project
(36.01 KB, application/zip)
2013-10-08 02:42 PDT
,
Axel Katerbau
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Axel Katerbau
Comment 1
2013-10-08 02:42:37 PDT
Created
attachment 213680
[details]
Corresponding Xcode project
Axel Katerbau
Comment 2
2013-10-08 03:05:35 PDT
Version used might be: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71
Radar WebKit Bug Importer
Comment 3
2013-10-09 02:29:44 PDT
<
rdar://problem/15184814
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug