Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka Library Crashes when using ProducerConfig with SetLogHandler / SetErrorHandler #1834

Open
3 of 8 tasks
albertherd opened this issue Jun 9, 2022 · 4 comments
Open
3 of 8 tasks

Comments

@albertherd
Copy link

albertherd commented Jun 9, 2022

Description

When creating a ProducerConfig and your application is running containerized (using the default Dockerfile from VS 2022), when a log is generated and is passed to the API, the application just terminates. It even ignores the try-catch (maybe there is no exception being raised), the application just terminates.

  • I reproduced this in nuget package version 1.8.2
  • OS is windows, but Docker container is Linux
  • You don't need a Kafka instance running
  • No logs are emitted
  • Tested on different machines, both Windows 10 and Windows 11

How to reproduce

You can see it life in action here: kafkaissue

The offending code is the following

new ProducerBuilder<string, string>(producerConfig) .SetValueSerializer(new JsonSerializer<string>(schemaRegistry)) .SetLogHandler((_, message) => Console.WriteLine("I am a log")) .SetErrorHandler((_, error) => Console.WriteLine("I am an error")) .Build();

If you do NOT run it containerized, it will fail with expected behaviour.

image

Checklist

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • Confluent.Kafka nuget version.
  • Apache Kafka version.
  • Client configuration.
  • Operating system.
  • Provide logs (with "debug" : "..." as necessary in configuration).
  • Provide broker log excerpts.
  • Critical issue.
@mhowlett mhowlett added bug investigate further we want to further investigate to understand properly labels Jun 9, 2022
@mhowlett
Copy link
Contributor

mhowlett commented Jun 9, 2022

this has been reported before.
i'll need to look into it.
seems like librdkafka is segfaulting

@vpa1977
Copy link

vpa1977 commented Nov 1, 2022

I have got following stacktrace on Ubuntu 22.10, 1.9.3 when using debugger.
No crash when running without it.
Could it be something runtime-related?

 thread #1, name = 'KafkaCrashRepor', stop reason = signal SIGTRAP
  * frame #0: 0x00007f0ac735fba1
    frame #1: 0x00007f0b2e6210fe librdkafka.so`rd_kafka_log0 + 670
    frame #2: 0x00007f0b2e630feb librdkafka.so`rd_kafka_broker_set_error + 667
    frame #3: 0x00007f0b2e632c2c librdkafka.so`rd_kafka_broker_fail + 316
    frame #4: 0x00007f0b2e632fa7 librdkafka.so`rd_kafka_broker_conn_closed + 71
    frame #5: 0x00007f0b2e63748e librdkafka.so`rd_kafka_recv + 638
    frame #6: 0x00007f0b2e65ac50 librdkafka.so`rd_kafka_transport_io_event.constprop.6 + 464
    frame #7: 0x00007f0b2e65b793 librdkafka.so`rd_kafka_transport_io_serve + 147
    frame #8: 0x00007f0b2e641fc4 librdkafka.so`rd_kafka_broker_ops_io_serve + 276
    frame #9: 0x00007f0b2e643e30 librdkafka.so`rd_kafka_broker_serve + 1008
    frame #10: 0x00007f0b2e64464d librdkafka.so`rd_kafka_broker_thread_main + 717
    frame #11: 0x00007f0b2e6bc2f7 librdkafka.so`_thrd_wrapper_function + 23
    frame #12: 0x00007f0b408bd402 libc.so.6`start_thread(arg=<unavailable>) at pthread_create.c:442:8
    frame #13: 0x00007f0b4094c590 libc.so.6`__clone3 at clone3.S:81
(lldb) ip2md 0x00007f0ac735fba1
MethodDesc:   00007f0ac740c128
Method Name:          Confluent.Kafka.Producer`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].LogCallback(IntPtr, Confluent.Kafka.SyslogLevel, System.String, System.String)
Class:                00007f0ac733df58
MethodTable:          00007f0ac740c220
mdToken:              00000000060002C6
Module:               00007f0ac7060f78
IsJitted:             yes
Current CodeAddr:     00007f0ac735fba0
Version History:
  ILCodeVersion:      0000000000000000
  ReJIT ID:           0
  IL Addr:            00007f0b3c0419a4
     CodeAddr:           00007f0ac735fba0  (MinOptJitted)
     NativeCodeVersion:  0000000000000000

@deNoor
Copy link

deNoor commented Jul 22, 2023

Since this issue is going to be the main one for consumer .SetLogHandler stealth crashes, let's mention here:

  • happens in net6.0 and net7.0, but works in net5.0;
  • happens with dotnet debugger attached and works without it.

I've tested with:
Visual Studio 2022 17.6.5,
Docker Desktop 4.21.1 (Windows 11, WSL2 mode),
container images mcr.microsoft.com/dotnet/runtime (5.0, 6.0, 7.0),
librdkafka 1.5.2, 1.9.0, 2.2.0 from https://packages.confluent.io/clients/deb buster/main amd64,
Confluent.Kafka 1.5.2, 1.9.3.

@henioStraszny
Copy link

I've tested on Debian and Confluent.Kafka 2.3.0 with the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants