{"action":"created","issue":{"url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/258","repository_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet","labels_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/258/labels{/name}","comments_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/258/comments","events_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/258/events","html_url":"https://github.com/confluentinc/confluent-kafka-dotnet/issues/258","id":240983764,"number":258,"title":"System.AccessViolationException","user":{"login":"EranOfer","id":13414515,"avatar_url":"https://avatars0.githubusercontent.com/u/13414515?v=3","gravatar_id":"","url":"https://api.github.com/users/EranOfer","html_url":"https://github.com/EranOfer","followers_url":"https://api.github.com/users/EranOfer/followers","following_url":"https://api.github.com/users/EranOfer/following{/other_user}","gists_url":"https://api.github.com/users/EranOfer/gists{/gist_id}","starred_url":"https://api.github.com/users/EranOfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EranOfer/subscriptions","organizations_url":"https://api.github.com/users/EranOfer/orgs","repos_url":"https://api.github.com/users/EranOfer/repos","events_url":"https://api.github.com/users/EranOfer/events{/privacy}","received_events_url":"https://api.github.com/users/EranOfer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-06T14:52:40Z","updated_at":"2017-07-06T16:04:39Z","closed_at":null,"body":"Description\r\n===========\r\nI am getting AccessViolationException in my testing   .\r\nversion Confluent.Kafka (0.11.0-RC1)\r\n\r\nSystem.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.\r\n   at Confluent.Kafka.Impl.LibRdKafka.NativeMethods.rd_kafka_consumer_poll(IntPtr rk, IntPtr timeout_ms)\r\n   at Confluent.Kafka.Impl.SafeKafkaHandle.ConsumerPoll(Message& message, IntPtr millisecondsTimeout)\r\n   at Confluent.Kafka.Consumer.Consume(Message& message, Int32 millisecondsTimeout)\r\n   at Confluent.Kafka.Consumer`2.Consume(Message`2& message, Int32 millisecondsTimeout)\r\n   at Confluent.Kafka.Consumer`2.Poll(TimeSpan timeout)\r\n   at .<ConsumptionsLoop>d__26.MoveNext()\r\n   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)\r\n   at KafkaConsumer.ConsumptionsLoop()\r\n   at System.Threading.Tasks.Task`1.InnerInvoke()\r\n   at System.Threading.Tasks.Task.Execute()\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)\r\n   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)\r\n   at System.Threading.ThreadPoolWorkQueue.Dispatch()\r\n\r\n\r\nHow to reproduce\r\n================\r\n\r\nRun polling loop in a thread started via Task.Run\r\nCall dispose on different thread .\r\n\r\n```\r\nconsumer = new Consumer<string, string>(configDictionary, stringDeserializer, stringDeserializer);\r\n\r\n//Constructor\r\nTask.Run (()=>{\r\nwhile (CancellationTokenSource.IsCancellationRequested == false)\r\n {\r\n  consumer.Poll(PollTimeOut);\r\n }\r\n});\r\n\r\npublic void Dispose()  {\r\nCancellationTokenSource.Cancel()\r\nconsumer.Dispose();\r\n}\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/comments/313441626","html_url":"https://github.com/confluentinc/confluent-kafka-dotnet/issues/258#issuecomment-313441626","issue_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/258","id":313441626,"user":{"login":"treziac","id":2729252,"avatar_url":"https://avatars3.githubusercontent.com/u/2729252?v=3","gravatar_id":"","url":"https://api.github.com/users/treziac","html_url":"https://github.com/treziac","followers_url":"https://api.github.com/users/treziac/followers","following_url":"https://api.github.com/users/treziac/following{/other_user}","gists_url":"https://api.github.com/users/treziac/gists{/gist_id}","starred_url":"https://api.github.com/users/treziac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treziac/subscriptions","organizations_url":"https://api.github.com/users/treziac/orgs","repos_url":"https://api.github.com/users/treziac/repos","events_url":"https://api.github.com/users/treziac/events{/privacy}","received_events_url":"https://api.github.com/users/treziac/received_events","type":"User","site_admin":false},"created_at":"2017-07-06T16:04:39Z","updated_at":"2017-07-06T16:04:39Z","body":"When you call cancel, you are not awaiting your task. Thus, followinf can happen:\r\n\r\n- On Poll thread: pass the test (not cancelled), jump to other thread\r\n- Cancel token\r\n- Begin dispose => destroy consumer handle\r\n- Jump back to poll thread: call Poll => crash, the handle was disposed\r\n\r\nYou need to wait your task"}}
{"actor":{"display_login":"treziac"}}