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

Broker connect getaddrinfo crash with concurrent producer and consumer #2207

Closed
3 tasks done
voelkerp opened this issue Jan 30, 2019 · 2 comments
Closed
3 tasks done

Comments

@voelkerp
Copy link

voelkerp commented Jan 30, 2019

Description

I have made an executable that creates one rd_kafka_t as producer and one as consumer in separate threads. When using only one at a time, they work correctly. When I create both at the same time, the executable crashes on the second call to rd_kafka_brokers_add(). I'm only adding a single broker but I do it once for each rd_kafka_t.

I've tried setting the broker via "bootstrap.servers" and that has the same effect.

The crash occurs under rd_kafka_broker_thread_main() and getaddrinfo() in internal_getent() (see entire callstack below.)

I'm unsure what else to try. Any help or tips appreciated.

Checklist

  • librdkafka version (release number or git tag): 0.11.5
  • librdkafka client configuration: internal.termination.signal=SIGIO
  • Operating system: Ubuntu 18.04.1 LTS

0x00007ffff0131448 in internal_getent (stream=stream@entry=0x7ffff002e670, result=result@entry=0x7fffd1ff8900, buffer=buffer@entry=0x7fffd1ff8d10 "",
buflen=buflen@entry=1024, errnop=errnop@entry=0x7fffd1ffb6b0, herrnop=herrnop@entry=0x7fffd1ffb6e8, af=0, flags=0) at nss_files/files-XXX.c:216
216 nss_files/files-XXX.c: No such file or directory.
(gdb) i stack
#0 0x00007ffff0131448 in internal_getent (stream=stream@entry=0x7ffff002e670, result=result@entry=0x7fffd1ff8900, buffer=buffer@entry=0x7fffd1ff8d10 "",
buflen=buflen@entry=1024, errnop=errnop@entry=0x7fffd1ffb6b0, herrnop=herrnop@entry=0x7fffd1ffb6e8, af=0, flags=0) at nss_files/files-XXX.c:216
#1 0x00007ffff01328bd in _nss_files_gethostbyname4_r (name=0x7fffd1ffa6a0 "xnode.second-bridge.net", pat=0x7fffd1ff8a88, buffer=0x7fffd1ff8d10 "", buflen=1024,
errnop=0x7fffd1ffb6b0, herrnop=0x7fffd1ffb6e8, ttlp=0x0) at nss_files/files-hosts.c:416
#2 0x0000000000791be5 in gaih_inet.constprop ()
#3 0x0000000000793b74 in getaddrinfo ()
#4 0x00000000004492ae in rd_getaddrinfo (nodesvc=, defsvc=0x7fffd1ffa7a0 "9092", flags=32, family=, socktype=,
protocol=, errstr=0x7fffd1ff9288) at ../../../Shared/librdkafka/src/rdaddr.c:168
#5 0x000000000046014a in rd_kafka_broker_resolve (rkb=) at ../../../Shared/librdkafka/src/rdkafka_broker.c:667
#6 rd_kafka_broker_connect (rkb=) at ../../../Shared/librdkafka/src/rdkafka_broker.c:1466
#7 rd_kafka_broker_thread_main (arg=0x7fffd8002dd0) at ../../../Shared/librdkafka/src/rdkafka_broker.c:3512
#8 0x00000000004be976 in _thrd_wrapper_function (aArg=) at ../../../Shared/librdkafka/src/tinycthread.c:624
#9 0x00000000004e0ebb in start_thread (arg=0x7fffd1ffb700) at pthread_create.c:463
#10 0x0000000000798f5f in clone ()

@rolandyoung
Copy link

Our application uses both consumer and producer instances simultaneously, but we create them one at a time from the same thread - the librdkafka code uses its own threads for all the hard work. Maybe serialising the startup would work around any thread safety issue in getaddrinfo.

@voelkerp
Copy link
Author

voelkerp commented Feb 2, 2019

Turns out I was compiling a static executable with "-static". There's documented issues with getaddrinfo and static compilation.

It works fine now that I've removed that compile switch. This issue can be closed.

@voelkerp voelkerp closed this as completed Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants