{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/24821","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/24821/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/24821/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/24821/events","html_url":"https://github.com/dotnet/corefx/issues/24821","id":267804960,"number":24821,"title":"ClientWebSocket produces malloc exception in multi-threaded environments.","user":{"login":"lwansbrough","id":186674,"avatar_url":"https://avatars0.githubusercontent.com/u/186674?v=4","gravatar_id":"","url":"https://api.github.com/users/lwansbrough","html_url":"https://github.com/lwansbrough","followers_url":"https://api.github.com/users/lwansbrough/followers","following_url":"https://api.github.com/users/lwansbrough/following{/other_user}","gists_url":"https://api.github.com/users/lwansbrough/gists{/gist_id}","starred_url":"https://api.github.com/users/lwansbrough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lwansbrough/subscriptions","organizations_url":"https://api.github.com/users/lwansbrough/orgs","repos_url":"https://api.github.com/users/lwansbrough/repos","events_url":"https://api.github.com/users/lwansbrough/events{/privacy}","received_events_url":"https://api.github.com/users/lwansbrough/received_events","type":"User","site_admin":false},"labels":[{"id":178058848,"url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.Net","name":"area-System.Net","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-23T20:23:44Z","updated_at":"2017-10-23T20:26:39Z","closed_at":null,"author_association":"NONE","body":"Running a .NET Core 2.0 CLI app on macOS 10.12.6. ClientWebSocket version is the latest I believe.\r\n\r\nWhen operating in a multi-threaded environment, I receive what looks like a C++ malloc exception.\r\n\r\nThis appears to be happening when the remote host terminates the connection unexpectedly. I have locks on reads + writes so there is never more than one of each happening at once. When I make a call to either `SendAsync` or `ReceiveAsync` and the connection has been terminated unexpectedly, I receive the following error:\r\n\r\n```\r\ndotnet(75902,0x700010355000) malloc: *** error for object 0x7fe5669dbf20: pointer being freed was not allocated\r\n*** set a breakpoint in malloc_error_break to debug\r\n```\r\n\r\nI can't say for certain whether or not the remote host has terminated the connection because I don't have a stack trace, but it is my suspicion as I know there is a rate limit on the web socket endpoint, and this issue only happens shortly after sustained requests exceed rate limit threshold.\r\n\r\nI can't think of any way of preventing this issue in user code (other than a rate limiter but that only stops a certain type of unexpected termination.)  Adding a lock won't solve it because the the connection could be terminated between when I call ReceiveAsync and when ReceiveAsync reaches the point in native code where it breaks."},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/338785931","html_url":"https://github.com/dotnet/corefx/issues/24821#issuecomment-338785931","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/24821","id":338785931,"user":{"login":"lwansbrough","id":186674,"avatar_url":"https://avatars0.githubusercontent.com/u/186674?v=4","gravatar_id":"","url":"https://api.github.com/users/lwansbrough","html_url":"https://github.com/lwansbrough","followers_url":"https://api.github.com/users/lwansbrough/followers","following_url":"https://api.github.com/users/lwansbrough/following{/other_user}","gists_url":"https://api.github.com/users/lwansbrough/gists{/gist_id}","starred_url":"https://api.github.com/users/lwansbrough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lwansbrough/subscriptions","organizations_url":"https://api.github.com/users/lwansbrough/orgs","repos_url":"https://api.github.com/users/lwansbrough/repos","events_url":"https://api.github.com/users/lwansbrough/events{/privacy}","received_events_url":"https://api.github.com/users/lwansbrough/received_events","type":"User","site_admin":false},"created_at":"2017-10-23T20:26:39Z","updated_at":"2017-10-23T20:26:39Z","author_association":"NONE","body":"Yeah sorry, I updated the question: Unix, macOS 10.12.6."}}
{"actor":{"display_login":"lwansbrough"}}