How can I get the librdkafka C++ producer example to work on Windows under the debugger?

0

I'm working on Windows, in Visual Studio 2019, using librdkafka.redist NuGet package v1.50.

I've literally copy/pasted the librdkafka producer.cpp example code into my empty C++ project, changing only one line to be as follows:

#include <librdkafka/rdkafkacpp.h>

I've also modified build/native/librdkafka.redist.targets, replacing occurrences of "librdkafka.lib" with "librdkafkacpp.lib", because I'm working in C++.

The command line arguments are "127.0.0.1 test", in all cases. I'm running Kafka locally, and the topic is "test".

With this setup, the project builds and runs just fine as a release executable. I can type strings to produce, and they are produced to topic test.

If I switch to a debug configuration (32 or 64 bit, it doesn't matter), the program builds just fine, but on running it, it crashes as soon as it attempts to call:

conf->set("bootstrap.servers", brokers, errstr)

brokers is indeed "127.0.0.1" when this crash happens.

This is right after calling:

RdKafka::Conf* conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);

I don't expect to step into the librdkafkacpp code, but it would be nice for it to actually function properly while running a debug executable.

I've also proven that the debug executable fails even if I don't run it under the debugger. It crashes with this error in the 64-bit exe.

Unhandled exception at 0x00007FF917F8C3F9 (msvcr120.dll) in KafkaFun.exe: 0xC0000005: Access violation reading location 0x0000002D4A150000.

Here's the error in the 32-bit exe:

Unhandled exception at 0x0100F41C (msvcr120.dll) in KafkaFun.exe: 0xC0000005: Access violation reading location 0xCD2BC8B0.

Something's clearly deeply wrong with the debug executables as I have built them. Do you have any idea what the problem is?

c++
windows
debugging
librdkafka
asked on Stack Overflow Aug 19, 2020 by John Paquette

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0