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 in DNS resolver SetCancelCallback #19

Closed
jvalenciag opened this issue Mar 31, 2017 · 6 comments
Closed

Segmentation fault in DNS resolver SetCancelCallback #19

jvalenciag opened this issue Mar 31, 2017 · 6 comments
Labels

Comments

@jvalenciag
Copy link

jvalenciag commented Mar 31, 2017

SIGSEGV (Segmentation fault) when calling connect using localhost in a TCPClient

I0331 15:47:23.219928 12023 tcp_client.cc:44] TCPClient::Connect remote_addr=localhost:9099
I0331 15:47:23.219969 12023 connector.cc:20] Connector::Connector this=0x555555785120 raddr=localhost:9099
I0331 15:47:23.219995 12023 sockets.cc:103] ParseFromIPPort inet_pton(AF_INET 'localhost', ...) rc=0. localhost is not a valid IP address. Maybe it is a hostname.
I0331 15:47:23.220072 12023 connector.cc:47] Try to connect localhost:9099 status=kDisconnected
I0331 15:47:23.220132 12023 inner_pre.cc:63] event_add ev=0x555555783ba0 fd=-1 user_ptr=0x555555786020 tid=140737353916160
I0331 15:47:23.220154 12023 connector.cc:59] The remote address localhost:9099 is a host, try to resolve its IP address.
I0331 15:47:23.220237 12023 dns_resolver.cc:22] DNSResolver::Start tid=140737353916160 this=0x555555784550
I0331 15:47:23.220242 12023 dns_resolver.cc:116] call shared_from_this
I0331 15:47:23.220360 12023 dns_resolver.cc:194] this->use_count=3
I0331 15:47:23.220412 12023 dns_resolver.cc:179] localhost resolved a ip=127.0.0.1

Stack trace

#0  0x000055555555d61d in std::swap<std::_Any_data> (__a=..., __b=...) at /usr/include/c++/6/bits/move.h:191
#1  0x00007ffff7b534ab in std::function<void ()>::swap(std::function<void ()>&) (this=0x7fffffffd830, __x=...) at /usr/include/c++/6/functional:2025
#2  0x00007ffff7b5244d in std::function<void ()>::operator=(std::function<void ()> const&) (this=0x40, __x=...) at /usr/include/c++/6/functional:1940
#3  0x00007ffff7b674cd in evpp::EventWatcher::SetCancelCallback(std::function<void ()> const&) (this=0x0, cb=...) at evpp/libevent_watcher.cc:96
#4  0x00007ffff7b574be in evpp::DNSResolver::ClearTimer (this=0x555555784550) at evpp/dns_resolver.cc:200
#5  0x00007ffff7b571f5 in evpp::DNSResolver::OnResolved (this=0x555555784550, errcode=0, addr=0x555555782b60) at evpp/dns_resolver.cc:182
#6  0x00007ffff7b57422 in evpp::DNSResolver::OnResolved (errcode=0, addr=0x555555782b60, arg=0x555555782910) at evpp/dns_resolver.cc:195
#7  0x00007ffff6ab8ce8 in evdns_getaddrinfo () from /usr/lib/x86_64-linux-gnu/libevent-2.0.so.5
#8  0x00007ffff7b56d3a in evpp::DNSResolver::AsyncDNSResolve (this=0x555555784550) at evpp/dns_resolver.cc:120
#9  0x00007ffff7b5635a in evpp::DNSResolver::<lambda()>::operator()(void) const (__closure=0x7fffffffdbe0) at evpp/dns_resolver.cc:26
#10 0x00007ffff7b57668 in std::_Function_handler<void(), evpp::DNSResolver::Start()::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/6/functional:1740
#11 0x00007ffff7b5afce in std::function<void ()>::operator()() const (this=0x7fffffffdbe0) at /usr/include/c++/6/functional:2136
#12 0x00007ffff7b5a360 in evpp::EventLoop::RunInLoop(std::function<void ()>&&) (this=0x7fffffffdef0, functor=<unknown type in /usr/local/lib/libevpp.so.0.3, CU 0x3c472, DIE 0x49ae8>) at evpp/event_loop.cc:207
#13 0x00007ffff7b563e2 in evpp::DNSResolver::Start (this=0x555555784550) at evpp/dns_resolver.cc:31
#14 0x00007ffff7b5034d in evpp::Connector::Start (this=0x555555785120) at evpp/connector.cc:66
#15 0x00007ffff7b6c396 in evpp::TCPClient::<lambda()>::operator()(void) const (__closure=0x7fffffffde00) at evpp/tcp_client.cc:49
#16 0x00007ffff7b6d4bc in std::_Function_handler<void(), evpp::TCPClient::Connect()::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/6/functional:1740
#17 0x00007ffff7b5afce in std::function<void ()>::operator()() const (this=0x7fffffffde00) at /usr/include/c++/6/functional:2136
#18 0x00007ffff7b5a360 in evpp::EventLoop::RunInLoop(std::function<void ()>&&) (this=0x7fffffffdef0, functor=<unknown type in /usr/local/lib/libevpp.so.0.3, CU 0x3c472, DIE 0x49ae8>) at evpp/event_loop.cc:207
#19 0x00007ffff7b6c48e in evpp::TCPClient::Connect (this=0x7fffffffdfe0) at evpp/tcp_client.cc:51
#20 0x000055555555bef1 in main (argc=1, argv=0x7fffffffe1d8) at /home/jvalencia/workspace/cnettests/client.cpp:61
@zieckey
Copy link
Collaborator

zieckey commented Apr 1, 2017

Please paste the whole code which can produce this issue. Thanks.

@jvalenciag
Copy link
Author

jvalenciag commented Apr 1, 2017

Is a simple TCPClient, I am ussing g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005

int main(int argc, char* argv[]) {
    evpp::EventLoop loop;
    evpp::TCPClient client (&loop,"localhost:9099","TestClient");

    client.SetConnectionCallback(&OnConnection);
    client.SetMessageCallback(&OnMessage);
    client.Connect();
    loop.Run();
    return 0;
}

@jvalenciag
Copy link
Author

Occurs only when using "localhost"

@zieckey
Copy link
Collaborator

zieckey commented Apr 1, 2017

OK, I am working on it.

@zieckey
Copy link
Collaborator

zieckey commented Apr 1, 2017

Please try again using the lastest code.
Thanks for reporting this bug.

@zieckey zieckey added the bug label Apr 1, 2017
@jvalenciag
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants