{"action":"created","issue":{"url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/3","repository_url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka","labels_url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/3/comments","events_url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/3/events","html_url":"https://github.com/didier-wenzek/ocaml-kafka/issues/3","id":139456793,"number":3,"title":"Kafka_lwt.consume_batch is not thread-safe","user":{"login":"cyberhuman","id":979624,"avatar_url":"https://avatars.githubusercontent.com/u/979624?v=3","gravatar_id":"","url":"https://api.github.com/users/cyberhuman","html_url":"https://github.com/cyberhuman","followers_url":"https://api.github.com/users/cyberhuman/followers","following_url":"https://api.github.com/users/cyberhuman/following{/other_user}","gists_url":"https://api.github.com/users/cyberhuman/gists{/gist_id}","starred_url":"https://api.github.com/users/cyberhuman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyberhuman/subscriptions","organizations_url":"https://api.github.com/users/cyberhuman/orgs","repos_url":"https://api.github.com/users/cyberhuman/repos","events_url":"https://api.github.com/users/cyberhuman/events{/privacy}","received_events_url":"https://api.github.com/users/cyberhuman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-09T02:35:34Z","updated_at":"2016-03-09T12:41:32Z","closed_at":null,"body":"I observe memory corruption when trying to run Kafka_lwt.consume_batch on the same topic object but different partitions in two Lwt threads. Is it supposed to work like this?"},"comment":{"url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/comments/194279537","html_url":"https://github.com/didier-wenzek/ocaml-kafka/issues/3#issuecomment-194279537","issue_url":"https://api.github.com/repos/didier-wenzek/ocaml-kafka/issues/3","id":194279537,"user":{"login":"didier-wenzek","id":4180916,"avatar_url":"https://avatars.githubusercontent.com/u/4180916?v=3","gravatar_id":"","url":"https://api.github.com/users/didier-wenzek","html_url":"https://github.com/didier-wenzek","followers_url":"https://api.github.com/users/didier-wenzek/followers","following_url":"https://api.github.com/users/didier-wenzek/following{/other_user}","gists_url":"https://api.github.com/users/didier-wenzek/gists{/gist_id}","starred_url":"https://api.github.com/users/didier-wenzek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/didier-wenzek/subscriptions","organizations_url":"https://api.github.com/users/didier-wenzek/orgs","repos_url":"https://api.github.com/users/didier-wenzek/repos","events_url":"https://api.github.com/users/didier-wenzek/events{/privacy}","received_events_url":"https://api.github.com/users/didier-wenzek/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T12:41:32Z","updated_at":"2016-03-09T12:41:32Z","body":"Reproduced. The following main leads to a segmentation fault:\r\n\r\n```ocaml\r\nopen Lwt\r\n\r\nlet rec count_message topic partition =\r\n   Kafka_lwt.consume_batch topic partition\r\n   >>= fun messages ->\r\n   Lwt_io.printl (string_of_int (List.length messages))\r\n   >>= fun () ->\r\n   count_message topic partition\r\n\r\nlet main =\r\n   let consumer = Kafka.new_consumer [\"metadata.broker.list\",\"localhost:9092\"] in\r\n   let topic = Kafka.new_topic consumer \"test\" [] in\r\n\r\n   Kafka.consume_start topic 0 Kafka.offset_end;\r\n   Kafka.consume_start topic 1 Kafka.offset_end;\r\n\r\n   Lwt.join [\r\n      count_message topic 0;\r\n      count_message topic 1\r\n   ]\r\n\r\nlet _ =\r\n  Lwt_main.run main\r\n```"}}