<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>122124</bug_id>
          
          <creation_ts>2013-09-30 14:34:53 -0700</creation_ts>
          <short_desc>Assertion failure under -[JSObjCClassInfo allocateConstructorAndPrototypeWithSuperClassInfo:] if no classes conform to JSExport</short_desc>
          <delta_ts>2013-09-30 15:51:22 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>mitz</reporter>
          <assigned_to>mitz</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>mhahnenberg</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>934811</commentid>
    <comment_count>0</comment_count>
    <who name="">mitz</who>
    <bug_when>2013-09-30 14:34:53 -0700</bug_when>
    <thetext>&lt;rdar://problem/15114974&gt;

Defining an NSBlock-valued property on a JSValue in a program that doesn’t load any classes that conform to JSExport causes an assertion failure.

To reproduce, build and run this:

#import &lt;JavaScriptCore/JavaScriptCore.h&gt;

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        JSContext *context = [[JSContext alloc] init];
        [[context globalObject] defineProperty:@&quot;doSomething&quot; descriptor:@{
            JSPropertyDescriptorValueKey : ^{ }
        }];
    }
    return 0;
}

* RESULTS
ASSERTION FAILED: target
Source/JavaScriptCore/API/ObjcRuntimeExtras.h(47) : void forEachProtocolImplementingProtocol(Class, Protocol *, void (^)(Protocol *))
1   0x1005d66f0 WTFCrash
2   0x1004120d0 forEachProtocolImplementingProtocol(objc_class*, Protocol*, void (Protocol*) block_pointer)
3   0x10040e92b -[JSObjCClassInfo allocateConstructorAndPrototypeWithSuperClassInfo:]
4   0x10040e0ab -[JSObjCClassInfo initWithContext:forClass:superClassInfo:]
5   0x10040ff2d -[JSWrapperMap classInfoForClass:]
6   0x10040fe5e -[JSWrapperMap classInfoForClass:]
7   0x10040fe5e -[JSWrapperMap classInfoForClass:]
8   0x10041008b -[JSWrapperMap jsWrapperForObject:]
9   0x100373d57 -[JSContext(Internal) wrapperForObjCObject:]
10  0x1003f868e objectToValueWithoutCopy(JSContext*, objc_object*)
11  0x1003f7ddf ObjcContainerConvertor::convert(objc_object*)
12  0x1003f3435 objectToValue(JSContext*, objc_object*)
13  0x1003f6016 -[JSValue invokeMethod:withArguments:]
14  0x1003f51d1 -[JSValue defineProperty:descriptor:]
15  0x100000e1f main
16  0x7fff878195fd start

* NOTES
This happens because objc_getProtocol(&quot;JSExport&quot;) returns nil. Note that getJSExportProtocol() caches this result, which means that if a class that conforms to JSExport is loaded (or registered dynamically) later, getJSExportProtocol() would still return nil. This seems like an actual correctness issue in production builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>934828</commentid>
    <comment_count>1</comment_count>
      <attachid>213038</attachid>
    <who name="">mitz</who>
    <bug_when>2013-09-30 15:00:08 -0700</bug_when>
    <thetext>Created attachment 213038
Define a class that conforms to the JSExport protocol in JavaScriptCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>934832</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2013-09-30 15:11:19 -0700</bug_when>
    <thetext>Is there a similar problem with the NSBlock class? If not, why not?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>934836</commentid>
    <comment_count>3</comment_count>
    <who name="">mitz</who>
    <bug_when>2013-09-30 15:23:02 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Is there a similar problem with the NSBlock class? If not, why not?

No. the NSBlock class is defined in Core Foundation, which JavaScriptCore links against. The only reason getNSBlockClass() doesn’t use [NSBlock self] is that the class is not declared in a public header.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>934841</commentid>
    <comment_count>4</comment_count>
      <attachid>213038</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-09-30 15:51:20 -0700</bug_when>
    <thetext>Comment on attachment 213038
Define a class that conforms to the JSExport protocol in JavaScriptCore.

Clearing flags on attachment: 213038

Committed r156684: &lt;http://trac.webkit.org/changeset/156684&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>934842</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-09-30 15:51:22 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>213038</attachid>
            <date>2013-09-30 15:00:08 -0700</date>
            <delta_ts>2013-09-30 15:51:20 -0700</delta_ts>
            <desc>Define a class that conforms to the JSExport protocol in JavaScriptCore.</desc>
            <filename>bug-122124-20130930150018.patch</filename>
            <type>text/plain</type>
            <size>1474</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMTU2NjgyKQorKysgU291cmNl
L0phdmFTY3JpcHRDb3J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LS0gU291cmNlL0phdmFTY3JpcHRDb3JlL0FQ
SS9KU1dyYXBwZXJNYXAubW0JKHJldmlzaW9uIDE1NjYwNykKKysrIFNvdXJjZS9KYXZhU2NyaXB0
Q29yZS9BUEkvSlNXcmFwcGVyTWFwLm1tCSh3b3JraW5nIGNvcHkpCkBAIC01MDYsNiArNTA2LDEy
IEBAIGlkIHRyeVVud3JhcE9iamNPYmplY3QoSlNHbG9iYWxDb250ZXh0UmUKICAgICByZXR1cm4g
bmlsOwogfQogCisvLyBUaGlzIGNsYXNzIGVuc3VyZXMgdGhhdCB0aGUgSlNFeHBvcnQgcHJvdG9j
b2wgaXMgcmVnaXN0ZXJlZCB3aXRoIHRoZSBydW50aW1lLgorTlNfUk9PVF9DTEFTUyBAaW50ZXJm
YWNlIEpTRXhwb3J0IDxKU0V4cG9ydD4KK0BlbmQKK0BpbXBsZW1lbnRhdGlvbiBKU0V4cG9ydAor
QGVuZAorCiBQcm90b2NvbCAqZ2V0SlNFeHBvcnRQcm90b2NvbCgpCiB7CiAgICAgc3RhdGljIFBy
b3RvY29sICpwcm90b2NvbCA9IG9iamNfZ2V0UHJvdG9jb2woIkpTRXhwb3J0Iik7Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>