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

Segmentation fault (core dumped) - reconnect using dns and multithread #973

Closed
yamoe opened this issue Aug 6, 2021 · 2 comments
Closed

Comments

@yamoe
Copy link

yamoe commented Aug 6, 2021

Segmentation fault occurs when reconnect occurs in multi-thread.

gdb> bt
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f6540976448 in internal_getent (stream=stream@entry=0x7f6540258490, result=result@entry=0x7f6540255b90,
    buffer=buffer@entry=0x7f6540255e00 "\377\377\377\377", buflen=buflen@entry=1024, errnop=errnop@entry=0x7f65402576b0,
    herrnop=herrnop@entry=0x7f65402576e8, af=2, flags=0) at nss_files/files-XXX.c:216
216     nss_files/files-XXX.c: No such file or directory.
[Current thread is 1 (Thread 0x7f6540257700 (LWP 24958))]
(gdb) bt
#0  0x00007f6540976448 in internal_getent (stream=stream@entry=0x7f6540258490, result=result@entry=0x7f6540255b90,
    buffer=buffer@entry=0x7f6540255e00 "\377\377\377\377", buflen=buflen@entry=1024, errnop=errnop@entry=0x7f65402576b0,
    herrnop=herrnop@entry=0x7f65402576e8, af=2, flags=0) at nss_files/files-XXX.c:216
#1  0x00007f65409776af in _nss_files_gethostbyname3_r (name=0x7f6538000b60 "localhost", af=2, result=0x7f6540255b90, buffer=<optimized out>,
    buflen=1024, errnop=0x7f65402576b0, herrnop=0x7f65402576e8, ttlp=0x0, canonp=0x0) at nss_files/files-hosts.c:352
#2  0x00007f6540977801 in _nss_files_gethostbyname2_r (name=<optimized out>, af=<optimized out>, result=<optimized out>,
    buffer=<optimized out>, buflen=<optimized out>, errnop=<optimized out>, herrnop=0x7f65402576e8) at nss_files/files-hosts.c:389
#3  0x00000000006125dd in gethostbyname2_r ()
#4  0x0000000000609994 in gaih_inet.constprop ()
#5  0x000000000060b624 in getaddrinfo ()
#6  0x0000000000499122 in _redisContextConnectTcp (c=c@entry=0x7f6538017d70, addr=addr@entry=0x7f6540256780 "localhost",
    port=port@entry=6001, timeout=timeout@entry=0x0, source_addr=source_addr@entry=0x0) at net.c:328
#7  0x0000000000499808 in redisContextConnectTcp (c=c@entry=0x7f6538017d70, addr=addr@entry=0x7f6540256780 "localhost", port=port@entry=6001,
    timeout=timeout@entry=0x0) at net.c:422
#8  0x000000000049384f in redisConnect (ip=0x7f6540256780 "localhost", port=6001) at hiredis.c:664
#9  0x000000000049b868 in sw::redis::Connection::Connector::_connect() const ()
#10 0x000000000049ba63 in sw::redis::Connection::Connector::connect() const ()
#11 0x000000000049cf90 in sw::redis::Connection::Connection(sw::redis::ConnectionOptions const&) ()
#12 0x000000000049d38e in sw::redis::Connection::reconnect() ()
#13 0x00000000004a2ad2 in sw::redis::ConnectionPool::fetch() ()
#14 0x00000000004b3cfc in std::enable_if<!std::is_convertible<void (*)(sw::redis::Connection&), sw::redis::StringView>::value, std::unique_ptr<redisReply, sw::redis::ReplyDeleter> >::type sw::redis::Redis::command<void (*)(sw::redis::Connection&)>(void (*)(sw::redis::Connection&)) ()
#15 0x00000000004ad6d7 in sw::redis::Redis::ping[abi:cxx11]() ()

I am using hiredis c0.14.0 and v1.0.0 is the same.

The reason is as follows.
https://sourceware.org/bugzilla/show_bug.cgi?id=10652

Currently, it is solved by one of the methods below.

  • use single thread (not use multi thread)
  • use dynamic link
  • use ip address (not dns)

If you have any other solution, please share.

thank you.

@yamoe yamoe changed the title Segmentation fault (core dumped) - Segmentation fault (core dumped) - reconnect using dns and multithread Aug 6, 2021
@michael-grunder
Copy link
Collaborator

This is interesting although I don't see how it's a bug with hiredis. This appears to be an issue with trying to statically link libpthread.a, which I suspect will cause all kinds of problems unless done very carefully.

@yamoe
Copy link
Author

yamoe commented Aug 10, 2021

thank you for your interest.
i will close this issue.

@yamoe yamoe closed this as completed Aug 10, 2021
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