morganstanley / modern-cpp-kafka

A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
Apache License 2.0
331 stars 86 forks source link

access violation when message send to wrong partition #216

Open yakovale-flutterint opened 11 months ago

yakovale-flutterint commented 11 months ago

Hi I faced an issue when 3 things are happening:

  1. i'm supplying headers for each message
  2. i'm sending to non existing partition
  3. before sending second message i'm waiting for CB to be triggered for first message

Please find a code sample that reproduce error below, it's a 'example_KafkaProducer_EnableManualEventsPoll.cc' from examples with small additions.

failing_example.txt

The result is when second send method is called, it fails in KafkaProducer.h #393 with error: Exception thrown: read access violation it was 0XFFFFFFFFFFFFFF

My environment is Windows 10 x64, VS 2019

Thanks in advance

kenneth-jia commented 11 months ago

Please be aware of the memory lifetime management, -- if you're not quite sure about it, just use SendOption::ToCopyRecordValue as the option for send(...)

yakovale-flutterint commented 11 months ago

i tried copy option too. Actually i just took example from this library and provided headers, no changes of example logics was done