{"action":"created","issue":{"url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/193","labels_url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/193/comments","events_url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/193/events","html_url":"https://github.com/VKCOM/vk-ios-sdk/issues/193","id":62984843,"number":193,"title":"Crash в VkRequest после processCommonError при waitUntilDone == YES.","user":{"login":"DMAPro","id":11556297,"avatar_url":"https://avatars.githubusercontent.com/u/11556297?v=3","gravatar_id":"","url":"https://api.github.com/users/DMAPro","html_url":"https://github.com/DMAPro","followers_url":"https://api.github.com/users/DMAPro/followers","following_url":"https://api.github.com/users/DMAPro/following{/other_user}","gists_url":"https://api.github.com/users/DMAPro/gists{/gist_id}","starred_url":"https://api.github.com/users/DMAPro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DMAPro/subscriptions","organizations_url":"https://api.github.com/users/DMAPro/orgs","repos_url":"https://api.github.com/users/DMAPro/repos","events_url":"https://api.github.com/users/DMAPro/events{/privacy}","received_events_url":"https://api.github.com/users/DMAPro/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-03-19T13:25:38Z","updated_at":"2015-03-20T13:06:59Z","closed_at":"2015-03-20T11:58:18Z","body":"Здравствуйте!\r\nСтолкнулся с ошибкой в случае, когда при выполнении запроса вернулся код 6 (слишком много запросов в секунду), а у VKRequest прописано `waitUntilDone = YES`.\r\nВ этом случае при первом вызове start поток остаётся висеть на \r\n\r\n    dispatch_semaphore_wait(_waitUntilDoneSemaphore, DISPATCH_TIME_FOREVER);\r\nЗатем вызывается `processCommonError`. Семафор в ней **не** освобождается. Она вызвыает `[self repeat]`, который вызывает `[self start]`. \r\nВ `[self start]` код доходит до строчки \r\n\r\n    _waitUntilDoneSemaphore = dispatch_semaphore_create(0);\r\nпосле чего падает. Я предполагаю, что пропадает единственная сильная ссылка на старый семафор, ARC пытается его удалить, что вызывает падение, т.к. того семафора ещё дожидается первый поток.\r\n\r\n> Thread : Crashed: com.apple.main-thread\r\n> 0  libdispatch.dylib              0x00000001957154e8 _dispatch_semaphore_dispose + 80\r\n> 1  libdispatch.dylib              0x0000000195715214 _dispatch_dispose + 56\r\n> 2  libdispatch.dylib              0x0000000195715214 _dispatch_dispose + 56\r\n> 3  libdispatch.dylib              0x0000000195711a8c -[OS_dispatch_object _xref_dispose] + 60\r\n> 4  VkProject                      0x00000001000fe8c8 -[VKRequest start] (VKRequest.m:276)\r\n> 5  VkProject                      0x00000001000ff91c -[VKRequest repeat] (VKRequest.m:358)\r\n> 6  VkProject                      0x00000001001007e0 __32-[VKRequest processCommonError:]_block_invoke (VKRequest.m:409)\r\n> 7  libdispatch.dylib              0x0000000195711994 _dispatch_call_block_and_release + 24\r\n> 8  libdispatch.dylib              0x0000000195711954 _dispatch_client_callout + 16\r\n> 9  libdispatch.dylib              0x000000019571b6f0 _dispatch_after_timer_callback + 92\r\n> 10 libdispatch.dylib              0x0000000195711954 _dispatch_client_callout + 16\r\n> 11 libdispatch.dylib              0x0000000195728010 _dispatch_source_latch_and_call + 2052\r\n> 12 libdispatch.dylib              0x0000000195713abc _dispatch_source_invoke + 288\r\n> 13 libdispatch.dylib              0x0000000195715dbc _dispatch_main_queue_callback_4CF + 504\r\n> 14 CoreFoundation                 0x00000001840ee2ec __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12\r\n> 15 CoreFoundation                 0x00000001840ec394 __CFRunLoopRun + 1492\r\n> 16 CoreFoundation                 0x00000001840191f4 CFRunLoopRunSpecific + 396\r\n> 17 GraphicsServices               0x000000018d4436fc GSEventRunModal + 168\r\n> 18 UIKit                          0x00000001889aa10c UIApplicationMain + 1488\r\n> 19 VkProject                      0x0000000100022c84 main (main.m:14)\r\n> 20 libdyld.dylib                  0x000000019573ea08 start + 4\r\n\r\nПо идее, та же проблема должна возникнуть при ошибке HTTPS is required, там обработчик похож.\r\n\r\nДля себя я решил проблему, реализовав ожидание завершения запроса через семафор (сам создаю семафор, и освобождаю его в completionBlock/errorBlock).\r\n\r\nВерсия SDK 1.1.0 (ставил через pod \"VK-ios-sdk\")."},"comment":{"url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/comments/84007664","html_url":"https://github.com/VKCOM/vk-ios-sdk/issues/193#issuecomment-84007664","issue_url":"https://api.github.com/repos/VKCOM/vk-ios-sdk/issues/193","id":84007664,"user":{"login":"DMAPro","id":11556297,"avatar_url":"https://avatars.githubusercontent.com/u/11556297?v=3","gravatar_id":"","url":"https://api.github.com/users/DMAPro","html_url":"https://github.com/DMAPro","followers_url":"https://api.github.com/users/DMAPro/followers","following_url":"https://api.github.com/users/DMAPro/following{/other_user}","gists_url":"https://api.github.com/users/DMAPro/gists{/gist_id}","starred_url":"https://api.github.com/users/DMAPro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DMAPro/subscriptions","organizations_url":"https://api.github.com/users/DMAPro/orgs","repos_url":"https://api.github.com/users/DMAPro/repos","events_url":"https://api.github.com/users/DMAPro/events{/privacy}","received_events_url":"https://api.github.com/users/DMAPro/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T13:06:58Z","updated_at":"2015-03-20T13:06:58Z","body":"@Dreddik Да, превосходно, большое спасибо! :)"}}