{"action":"created","issue":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15439","repository_url":"https://api.github.com/repos/cocos2d/cocos2d-x","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15439/labels{/name}","comments_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15439/comments","events_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15439/events","html_url":"https://github.com/cocos2d/cocos2d-x/issues/15439","id":148850415,"number":15439,"title":"EXC_BAD_ACCESS Random crashes on iOS context presentRenderbuffer","user":{"login":"Obg1","id":2327620,"avatar_url":"https://avatars.githubusercontent.com/u/2327620?v=3","gravatar_id":"","url":"https://api.github.com/users/Obg1","html_url":"https://github.com/Obg1","followers_url":"https://api.github.com/users/Obg1/followers","following_url":"https://api.github.com/users/Obg1/following{/other_user}","gists_url":"https://api.github.com/users/Obg1/gists{/gist_id}","starred_url":"https://api.github.com/users/Obg1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Obg1/subscriptions","organizations_url":"https://api.github.com/users/Obg1/orgs","repos_url":"https://api.github.com/users/Obg1/repos","events_url":"https://api.github.com/users/Obg1/events{/privacy}","received_events_url":"https://api.github.com/users/Obg1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/labels/critical","name":"critical","color":"e11d21"},{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/labels/platform:ios","name":"platform:ios","color":"fbca04"},{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/labels/type:bug","name":"type:bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"ricardoquesada","id":232330,"avatar_url":"https://avatars.githubusercontent.com/u/232330?v=3","gravatar_id":"","url":"https://api.github.com/users/ricardoquesada","html_url":"https://github.com/ricardoquesada","followers_url":"https://api.github.com/users/ricardoquesada/followers","following_url":"https://api.github.com/users/ricardoquesada/following{/other_user}","gists_url":"https://api.github.com/users/ricardoquesada/gists{/gist_id}","starred_url":"https://api.github.com/users/ricardoquesada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricardoquesada/subscriptions","organizations_url":"https://api.github.com/users/ricardoquesada/orgs","repos_url":"https://api.github.com/users/ricardoquesada/repos","events_url":"https://api.github.com/users/ricardoquesada/events{/privacy}","received_events_url":"https://api.github.com/users/ricardoquesada/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/milestones/27","html_url":"https://github.com/cocos2d/cocos2d-x/milestones/3.12","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/milestones/27/labels","id":1460593,"number":27,"title":"3.12","description":"","creator":{"login":"pandamicro","id":632460,"avatar_url":"https://avatars.githubusercontent.com/u/632460?v=3","gravatar_id":"","url":"https://api.github.com/users/pandamicro","html_url":"https://github.com/pandamicro","followers_url":"https://api.github.com/users/pandamicro/followers","following_url":"https://api.github.com/users/pandamicro/following{/other_user}","gists_url":"https://api.github.com/users/pandamicro/gists{/gist_id}","starred_url":"https://api.github.com/users/pandamicro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandamicro/subscriptions","organizations_url":"https://api.github.com/users/pandamicro/orgs","repos_url":"https://api.github.com/users/pandamicro/repos","events_url":"https://api.github.com/users/pandamicro/events{/privacy}","received_events_url":"https://api.github.com/users/pandamicro/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":125,"state":"open","created_at":"2015-12-15T02:48:07Z","updated_at":"2016-05-24T14:30:31Z","due_on":"2016-06-29T16:00:00Z","closed_at":null},"comments":22,"created_at":"2016-04-16T12:59:45Z","updated_at":"2016-05-24T14:30:31Z","closed_at":"2016-05-24T14:30:31Z","body":"I'm getting random crashes at:\r\n\r\n```\r\nif(![context_ presentRenderbuffer:GL_RENDERBUFFER])\r\nFile: CCEAGLView-ios.mm\r\n```\r\nEXC_BAD_ACCESS (code=1, address 0x1)\r\n\r\n\r\nOK, I was finally able to identify the cause for it.\r\nThe bug is because of the new static __indices in QuadCommand:\r\n\r\n```\r\nvoid QuadCommand::reIndex(int indicesCount)\r\n{\r\n    if (indicesCount > __indexCapacity)\r\n    {\r\n        CCLOG(\"cocos2d: QuadCommand: resizing index size from [%d] to [%d]\", __indexCapacity, indicesCount);\r\n        __indices = (GLushort*) realloc(__indices, indicesCount * sizeof(__indices[0]));\r\n        __indexCapacity = indicesCount;\r\n    }\r\n```\r\nWhen calling realloc, it moves the memory that is being used by OpenGl, thus causing the BAD ACCESS error.\r\nI was able to \"Fix\" it by calling realloc with null (will work like malloc):\r\n\r\n`  __indices = (GLushort*) realloc(nullptr, indicesCount * sizeof(__indices[0]));`"},"comment":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/comments/221289509","html_url":"https://github.com/cocos2d/cocos2d-x/issues/15439#issuecomment-221289509","issue_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15439","id":221289509,"user":{"login":"ricardoquesada","id":232330,"avatar_url":"https://avatars.githubusercontent.com/u/232330?v=3","gravatar_id":"","url":"https://api.github.com/users/ricardoquesada","html_url":"https://github.com/ricardoquesada","followers_url":"https://api.github.com/users/ricardoquesada/followers","following_url":"https://api.github.com/users/ricardoquesada/following{/other_user}","gists_url":"https://api.github.com/users/ricardoquesada/gists{/gist_id}","starred_url":"https://api.github.com/users/ricardoquesada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricardoquesada/subscriptions","organizations_url":"https://api.github.com/users/ricardoquesada/orgs","repos_url":"https://api.github.com/users/ricardoquesada/repos","events_url":"https://api.github.com/users/ricardoquesada/events{/privacy}","received_events_url":"https://api.github.com/users/ricardoquesada/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T14:30:31Z","updated_at":"2016-05-24T14:30:31Z","body":"I took a look at it. @Rypac 's approach is the correct one. No dependencies with the Events should be added for this fix. Merged rypac's PR"}}
{"actor":{"display_login":"ricardoquesada"}}