{"action":"created","issue":{"url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/509","repository_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet","labels_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/509/labels{/name}","comments_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/509/comments","events_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/509/events","html_url":"https://github.com/confluentinc/confluent-kafka-dotnet/pull/509","id":314819775,"number":509,"title":"protect rd_kafka_destroy references from GC","user":{"login":"mhowlett","id":19174,"avatar_url":"https://avatars2.githubusercontent.com/u/19174?v=4","gravatar_id":"","url":"https://api.github.com/users/mhowlett","html_url":"https://github.com/mhowlett","followers_url":"https://api.github.com/users/mhowlett/followers","following_url":"https://api.github.com/users/mhowlett/following{/other_user}","gists_url":"https://api.github.com/users/mhowlett/gists{/gist_id}","starred_url":"https://api.github.com/users/mhowlett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhowlett/subscriptions","organizations_url":"https://api.github.com/users/mhowlett/orgs","repos_url":"https://api.github.com/users/mhowlett/repos","events_url":"https://api.github.com/users/mhowlett/events{/privacy}","received_events_url":"https://api.github.com/users/mhowlett/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-16T21:12:09Z","updated_at":"2018-05-23T18:22:18Z","closed_at":"2018-04-27T15:58:37Z","author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/pulls/509","html_url":"https://github.com/confluentinc/confluent-kafka-dotnet/pull/509","diff_url":"https://github.com/confluentinc/confluent-kafka-dotnet/pull/509.diff","patch_url":"https://github.com/confluentinc/confluent-kafka-dotnet/pull/509.patch"},"body":"@edenhill - this addresses #508 \r\n\r\nIt seems clear that the issue is the order of object garbage collection is undefined, so it is unsafe to call through to rd_kafka_destroy in the finalizer of a producer/consumer. It's not completely clear to me from the stack trace in the issue exactly what object is being referenced, and it's difficult for me to replicate the issue, so I'm playing it safe and assuming it could be one of two. The `GCHandle.Alloc` call basically just marks an object as being referenced, so the GC will never collect it (it's not pinned though, so the object will move to generation 2 and not interfere with GC efficiency). I could reference count producer / consumer construction / destruction, and do a corresponding `GCHandle.Free`, but this would require substantial effort/complexity, and I see little point.\r\n"},"comment":{"url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/comments/391449040","html_url":"https://github.com/confluentinc/confluent-kafka-dotnet/pull/509#issuecomment-391449040","issue_url":"https://api.github.com/repos/confluentinc/confluent-kafka-dotnet/issues/509","id":391449040,"user":{"login":"mhowlett","id":19174,"avatar_url":"https://avatars2.githubusercontent.com/u/19174?v=4","gravatar_id":"","url":"https://api.github.com/users/mhowlett","html_url":"https://github.com/mhowlett","followers_url":"https://api.github.com/users/mhowlett/followers","following_url":"https://api.github.com/users/mhowlett/following{/other_user}","gists_url":"https://api.github.com/users/mhowlett/gists{/gist_id}","starred_url":"https://api.github.com/users/mhowlett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhowlett/subscriptions","organizations_url":"https://api.github.com/users/mhowlett/orgs","repos_url":"https://api.github.com/users/mhowlett/repos","events_url":"https://api.github.com/users/mhowlett/events{/privacy}","received_events_url":"https://api.github.com/users/mhowlett/received_events","type":"User","site_admin":false},"created_at":"2018-05-23T18:22:18Z","updated_at":"2018-05-23T18:22:18Z","author_association":"COLLABORATOR","body":"thanks for the feedback\r\n\r\nthis PR was merged after 0.11.4 (so not in a release yet).\r\n\r\ngenerally, it's a bad idea to be relying on finalizers to clean up - best to make sure you're calling `Dispose` explicitly."}}
{"actor":{"display_login":"mhowlett"}}