{"action":"closed","issue":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/2189","repository_url":"https://api.github.com/repos/Alamofire/Alamofire","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/2189/labels{/name}","comments_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/2189/comments","events_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/2189/events","html_url":"https://github.com/Alamofire/Alamofire/issues/2189","id":240042132,"number":2189,"title":"Thread sanitizer issue during retry","user":{"login":"jshier","id":51020,"avatar_url":"https://avatars0.githubusercontent.com/u/51020?v=4","gravatar_id":"","url":"https://api.github.com/users/jshier","html_url":"https://github.com/jshier","followers_url":"https://api.github.com/users/jshier/followers","following_url":"https://api.github.com/users/jshier/following{/other_user}","gists_url":"https://api.github.com/users/jshier/gists{/gist_id}","starred_url":"https://api.github.com/users/jshier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshier/subscriptions","organizations_url":"https://api.github.com/users/jshier/orgs","repos_url":"https://api.github.com/users/jshier/repos","events_url":"https://api.github.com/users/jshier/events{/privacy}","received_events_url":"https://api.github.com/users/jshier/received_events","type":"User","site_admin":false},"labels":[{"id":118362600,"url":"https://api.github.com/repos/Alamofire/Alamofire/labels/bug","name":"bug","color":"ff3333","default":true}],"state":"closed","locked":false,"assignee":{"login":"jshier","id":51020,"avatar_url":"https://avatars0.githubusercontent.com/u/51020?v=4","gravatar_id":"","url":"https://api.github.com/users/jshier","html_url":"https://github.com/jshier","followers_url":"https://api.github.com/users/jshier/followers","following_url":"https://api.github.com/users/jshier/following{/other_user}","gists_url":"https://api.github.com/users/jshier/gists{/gist_id}","starred_url":"https://api.github.com/users/jshier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshier/subscriptions","organizations_url":"https://api.github.com/users/jshier/orgs","repos_url":"https://api.github.com/users/jshier/repos","events_url":"https://api.github.com/users/jshier/events{/privacy}","received_events_url":"https://api.github.com/users/jshier/received_events","type":"User","site_admin":false},"assignees":[{"login":"jshier","id":51020,"avatar_url":"https://avatars0.githubusercontent.com/u/51020?v=4","gravatar_id":"","url":"https://api.github.com/users/jshier","html_url":"https://github.com/jshier","followers_url":"https://api.github.com/users/jshier/followers","following_url":"https://api.github.com/users/jshier/following{/other_user}","gists_url":"https://api.github.com/users/jshier/gists{/gist_id}","starred_url":"https://api.github.com/users/jshier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshier/subscriptions","organizations_url":"https://api.github.com/users/jshier/orgs","repos_url":"https://api.github.com/users/jshier/repos","events_url":"https://api.github.com/users/jshier/events{/privacy}","received_events_url":"https://api.github.com/users/jshier/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Alamofire/Alamofire/milestones/41","html_url":"https://github.com/Alamofire/Alamofire/milestone/41","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/milestones/41/labels","id":2607432,"number":41,"title":"4.6.0","description":"","creator":{"login":"cnoon","id":169110,"avatar_url":"https://avatars1.githubusercontent.com/u/169110?v=4","gravatar_id":"","url":"https://api.github.com/users/cnoon","html_url":"https://github.com/cnoon","followers_url":"https://api.github.com/users/cnoon/followers","following_url":"https://api.github.com/users/cnoon/following{/other_user}","gists_url":"https://api.github.com/users/cnoon/gists{/gist_id}","starred_url":"https://api.github.com/users/cnoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnoon/subscriptions","organizations_url":"https://api.github.com/users/cnoon/orgs","repos_url":"https://api.github.com/users/cnoon/repos","events_url":"https://api.github.com/users/cnoon/events{/privacy}","received_events_url":"https://api.github.com/users/cnoon/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":4,"state":"open","created_at":"2017-06-27T14:44:46Z","updated_at":"2017-08-22T05:11:21Z","due_on":"2017-08-27T07:00:00Z","closed_at":null},"comments":0,"created_at":"2017-07-02T23:43:51Z","updated_at":"2017-08-22T05:11:21Z","closed_at":"2017-08-22T05:11:21Z","body":"* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/Alamofire/Alamofire/blob/master/CONTRIBUTING.md).\r\n\r\n## What did you do?\r\n\r\nRunning tests under Xcode 9 with the thread sanitizer active stops at this issue:\r\n\r\n```\r\nTest Case '-[Alamofire_macOS_Tests.SessionManagerTestCase testThatSessionManagerCallsRequestRetrierWhenUploadInitiallyEncountersAdaptError]' started.\r\n==================\r\nWARNING: ThreadSanitizer: data race (pid=1708)\r\n  Write of size 8 at 0x7b480007cb20 by thread T11:\r\n  * #0 TaskDelegate.task.setter TaskDelegate.swift (Alamofire:x86_64+0xddcd0)\r\n    #1 SessionManager.retry(_:) SessionManager.swift:858 (Alamofire:x86_64+0x98f7f)\r\n    #2 closure #1 in closure #1 in closure #1 in SessionManager.allowRetrier(_:toRetry:with:) SessionManager.swift:888 (Alamofire:x86_64+0x9b0ed)\r\n    #3 partial apply for closure #1 in closure #1 in closure #1 in SessionManager.allowRetrier(_:toRetry:with:) SessionManager.swift (Alamofire:x86_64+0x9b454)\r\n    #4 thunk for @callee_owned () -> () Request.swift (Alamofire:x86_64+0x3caac)\r\n    #5 __tsan::invoke_and_release_block(void*) <null>:6428064 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x6565b)\r\n    #6 _dispatch_client_callout <null>:6428064 (libdispatch.dylib:x86_64+0x1c25)\r\n\r\n  Previous read of size 8 at 0x7b480007cb20 by main thread:\r\n  * #0 TaskDelegate.task.getter TaskDelegate.swift (Alamofire:x86_64+0xddbd4)\r\n    #1 Request.task.getter Request.swift:102 (Alamofire:x86_64+0x39a77)\r\n    #2 Request.request.getter Request.swift:108 (Alamofire:x86_64+0x39b5b)\r\n    #3 DataRequest.request.getter Request.swift:370 (Alamofire:x86_64+0x484d7)\r\n    #4 UploadRequest.request.getter Request.swift:587 (Alamofire:x86_64+0x50ac6)\r\n    #5 Request.acceptableContentTypes.getter Validation.swift:78 (Alamofire:x86_64+0xfc8ee)\r\n    #6 DataRequest.validate() Validation.swift:216 (Alamofire:x86_64+0xffeff)\r\n    #7 SessionManagerTestCase.testThatSessionManagerCallsRequestRetrierWhenUploadInitiallyEncountersAdaptError() SessionManagerTests.swift:692 (Alamofire macOS Tests:x86_64+0x20f990)\r\n    #8 @objc SessionManagerTestCase.testThatSessionManagerCallsRequestRetrierWhenUploadInitiallyEncountersAdaptError() SessionManagerTests.swift (Alamofire macOS Tests:x86_64+0x213160)\r\n    #9 __invoking___ <null>:6428064 (CoreFoundation:x86_64h+0x8265b)\r\n\r\n  Issue is caused by frames marked with \"*\".\r\n\r\n  Location is heap block of size 344 at 0x7b480007cb00 allocated by main thread:\r\n    #0 calloc <null>:6428096 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x481b2)\r\n    #1 class_createInstance <null>:6428096 (libobjc.A.dylib:x86_64h+0x6ce9)\r\n    #2 Request.init(session:requestTask:error:) Request.swift:139 (Alamofire:x86_64+0x3ba91)\r\n    #3 DataRequest.init(session:requestTask:error:) Request.swift (Alamofire:x86_64+0x49cac)\r\n    #4 UploadRequest.init(session:requestTask:error:) Request.swift (Alamofire:x86_64+0x5208c)\r\n    #5 UploadRequest.__allocating_init(session:requestTask:error:) Request.swift (Alamofire:x86_64+0x51740)\r\n    #6 SessionManager.upload(_:failedWith:) SessionManager.swift:777 (Alamofire:x86_64+0x971b6)\r\n    #7 SessionManager.upload(_:) SessionManager.swift:765 (Alamofire:x86_64+0x95f65)\r\n    #8 SessionManager.upload(_:with:) SessionManager.swift:536 (Alamofire:x86_64+0x90fd7)\r\n    #9 SessionManager.upload(_:to:method:headers:) SessionManager.swift:518 (Alamofire:x86_64+0x90bf6)\r\n    #10 SessionManagerTestCase.testThatSessionManagerCallsRequestRetrierWhenUploadInitiallyEncountersAdaptError() SessionManagerTests.swift:691 (Alamofire macOS Tests:x86_64+0x20f95f)\r\n    #11 @objc SessionManagerTestCase.testThatSessionManagerCallsRequestRetrierWhenUploadInitiallyEncountersAdaptError() SessionManagerTests.swift (Alamofire macOS Tests:x86_64+0x213160)\r\n    #12 __invoking___ <null>:6428096 (CoreFoundation:x86_64h+0x8265b)\r\n\r\n  Thread T11 (tid=74951, running) is a GCD worker thread\r\n\r\nSUMMARY: ThreadSanitizer: data race TaskDelegate.swift in TaskDelegate.task.setter\r\n==================\r\nThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.\r\n```\r\n\r\n`thread info -s` returns this info:\r\n\r\n```\r\n(lldb) thread info -s\r\nthread #13: tid = 0x124c7, 0x0000000100160990 libclang_rt.tsan_osx_dynamic.dylib`__tsan_on_report, queue = 'com.apple.root.utility-qos', stop reason = Data race detected\r\n\r\n{\r\n  \"all_addresses_are_same\" : true,\r\n  \"description\" : \"Data race\",\r\n  \"instrumentation_class\" : \"ThreadSanitizer\",\r\n  \"issue_type\" : \"data-race\",\r\n  \"location_description\" : \"Location is a 344-byte heap object at 0x7b480007cb00\",\r\n  \"locs\" : [\r\n    {\r\n      \"address\" : 0,\r\n      \"file_descriptor\" : 0,\r\n      \"index\" : 0,\r\n      \"object_type\" : \"\",\r\n      \"size\" : 344,\r\n      \"start\" : 135549168372480,\r\n      \"suppressable\" : 0,\r\n      \"thread_id\" : 1,\r\n      \"trace\" : [\r\n        4296327603,\r\n        140737018109162,\r\n        4422261394,\r\n        4422319277,\r\n        4422353037,\r\n        4422350657,\r\n        4422635959,\r\n        4422631270,\r\n        4422610904,\r\n        4422609911,\r\n        4416629088,\r\n        4416643425,\r\n        140736373343836\r\n      ],\r\n      \"type\" : \"heap\"\r\n    }\r\n  ],\r\n  \"memory_address\" : 135549168372512,\r\n  \"mops\" : [\r\n    {\r\n      \"address\" : 135549168372512,\r\n      \"index\" : 0,\r\n      \"is_atomic\" : false,\r\n      \"is_write\" : true,\r\n      \"size\" : 8,\r\n      \"thread_id\" : 13,\r\n      \"trace\" : [\r\n        4422925521,\r\n        4422643584,\r\n        4422652142,\r\n        4422653013,\r\n        4422265517,\r\n        4296447580,\r\n        140737030372390\r\n      ]\r\n    },\r\n    {\r\n      \"address\" : 135549168372512,\r\n      \"index\" : 1,\r\n      \"is_atomic\" : false,\r\n      \"is_write\" : false,\r\n      \"size\" : 8,\r\n      \"thread_id\" : 1,\r\n      \"trace\" : [\r\n        4422925269,\r\n        4422253176,\r\n        4422253404,\r\n        4422313176,\r\n        4422347463,\r\n        4423051503,\r\n        4423065344,\r\n        4416629137,\r\n        4416643425,\r\n        140736373343836\r\n      ]\r\n    }\r\n  ],\r\n  \"mutexes\" : [\r\n\r\n  ],\r\n  \"report_count\" : 0,\r\n  \"sleep_trace\" : [\r\n\r\n  ],\r\n  \"stacks\" : [\r\n\r\n  ],\r\n  \"stop_description\" : \"Data race detected\",\r\n  \"summary\" : \"Data race in Alamofire.TaskDelegate.task.setter : Swift.Optional<__C.URLSessionTask> at 0x7b480007cb00\",\r\n  \"threads\" : [\r\n    {\r\n      \"index\" : 0,\r\n      \"name\" : \"\",\r\n      \"parent_thread_id\" : 0,\r\n      \"running\" : 1,\r\n      \"thread_id\" : 13,\r\n      \"thread_os_id\" : 74951,\r\n      \"trace\" : [\r\n\r\n      ]\r\n    },\r\n    {\r\n      \"index\" : 1,\r\n      \"name\" : \"\",\r\n      \"parent_thread_id\" : 1,\r\n      \"running\" : 1,\r\n      \"thread_id\" : 1,\r\n      \"thread_os_id\" : 73397,\r\n      \"trace\" : [\r\n\r\n      ]\r\n    }\r\n  ],\r\n  \"unique_tids\" : [\r\n\r\n  ]\r\n}\r\n```\r\n\r\nI will continue to investigate. These issues don't appear under Swift 3.2 mode.\r\n\r\n## Alamofire Environment\r\n\r\n**Alamofire version:** 4.5\r\n**Xcode version:** 9.0b2\r\n**Swift version:** 4\r\n**Platform(s) running Alamofire:** macOS\r\n**macOS version running Xcode:** High Sierra DP2\r\n"}}
{"actor":{"display_login":"cnoon"}}