{"action":"created","issue":{"url":"https://api.github.com/repos/ccgus/CocoaScript/issues/8","labels_url":"https://api.github.com/repos/ccgus/CocoaScript/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/ccgus/CocoaScript/issues/8/comments","events_url":"https://api.github.com/repos/ccgus/CocoaScript/issues/8/events","html_url":"https://github.com/ccgus/CocoaScript/issues/8","id":28649621,"number":8,"title":"cosscript crash with long running scripts","user":{"login":"afedor","id":6344186,"avatar_url":"https://avatars.githubusercontent.com/u/6344186?v=3","gravatar_id":"","url":"https://api.github.com/users/afedor","html_url":"https://github.com/afedor","followers_url":"https://api.github.com/users/afedor/followers","following_url":"https://api.github.com/users/afedor/following{/other_user}","gists_url":"https://api.github.com/users/afedor/gists{/gist_id}","starred_url":"https://api.github.com/users/afedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedor/subscriptions","organizations_url":"https://api.github.com/users/afedor/orgs","repos_url":"https://api.github.com/users/afedor/repos","events_url":"https://api.github.com/users/afedor/events{/privacy}","received_events_url":"https://api.github.com/users/afedor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2014-03-03T19:35:21Z","updated_at":"2015-04-03T18:56:18Z","closed_at":null,"body":"I think this is very similar to issue #5 but I though I'd leave a simple example script that illistrates it for me. It really only appears in 10.9 for me.  I've spent a lot of time trying to find the cause but most of the JavaScript stuff is black magic to me.  It appears though that due to some garbage collection, javascript objects are disappearing before I'm done using them, but this really only manifests itself when you have a long running javascript script.  I even went back and bisected the JavaScriptCore framework to find where the change might have started. I found something around Jun 2012 that when I reverted fixed the problem in most cases (I can give you the exact rev if you want), but that didn't really help with the real problem of finding how I could update CocoaScript to avoid the problem.\r\n\r\nAnyway, here's the script.  It always seems to crash for me around loop 26, with:\r\n1   0x7fff8d1a0fbc JSC::JSValue::get(JSC::ExecState*, unsigned int, JSC::PropertySlot&) const\r\n2   0x7fff8d1d06fa JSC::getByVal(JSC::ExecState*, JSC::JSValue, JSC::JSValue, JSC::ReturnAddressPtr)\r\n3   0x7fff8d1d034e cti_op_get_by_val_generic\r\n4   0x5971a9c02bd7\r\n5   0x7fff8d1168b6 JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*)\r\n6   0x7fff8d1156b6 JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, JSC::JSValue*)\r\n7   0x7fff8d1153ad JSEvaluateScript\r\n8   0x106c1a535 -[Mocha evalJSString:scriptPath:]\r\n9   0x106c1a405 -[Mocha evalJSString:]\r\n10  0x106c1a34a -[Mocha evalString:]\r\n11  0x106c3d1fc -[COScript executeString:baseURL:]\r\n12  0x106c3cf8a -[COScript executeString:]\r\n13  0x106c3b1eb main\r\n14  0x7fff969955fd start\r\n\r\n==== script ====\r\nvar toClass = {}.toString;\r\nvar itemDictPath = \"/Applications/Xcode.app/Contents/Info.plist\";\r\nvar itemDict = NSDictionary.dictionaryWithContentsOfFile_(itemDictPath);\r\nvar itemList = itemDict[\"CFBundleDocumentTypes\"];\r\n\r\nfunction readDict(item) {\r\n\tvar name = item[\"CFBundleTypeName\"];\r\n\tvar role = item[\"CFBundleTypeRole\"];\r\n\tprint(\"name class length \" + name.length());\r\n\t//NSLog(\"role class \" + role.class() + \" length \" + role.length());\r\n}\r\n\r\nfor (var j = 0; j < 100; j++) {\r\n  print(\" === LOOP \" + j + \" ====\");\r\n  for (var i = 0; i < itemList.count(); i++) {\r\n\treadDict(itemList[i]);\r\n  }\r\n}\r\n"},"comment":{"url":"https://api.github.com/repos/ccgus/CocoaScript/issues/comments/89391512","html_url":"https://github.com/ccgus/CocoaScript/issues/8#issuecomment-89391512","issue_url":"https://api.github.com/repos/ccgus/CocoaScript/issues/8","id":89391512,"user":{"login":"afedor","id":6344186,"avatar_url":"https://avatars.githubusercontent.com/u/6344186?v=3","gravatar_id":"","url":"https://api.github.com/users/afedor","html_url":"https://github.com/afedor","followers_url":"https://api.github.com/users/afedor/followers","following_url":"https://api.github.com/users/afedor/following{/other_user}","gists_url":"https://api.github.com/users/afedor/gists{/gist_id}","starred_url":"https://api.github.com/users/afedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedor/subscriptions","organizations_url":"https://api.github.com/users/afedor/orgs","repos_url":"https://api.github.com/users/afedor/repos","events_url":"https://api.github.com/users/afedor/events{/privacy}","received_events_url":"https://api.github.com/users/afedor/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T18:56:18Z","updated_at":"2015-04-03T18:56:18Z","body":"FYI #24 is not related to this bug, although it does help a bit."}}