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

multiple waiting requests and evdns_shutdown() cause SIGSEGV. #113

Closed
yasuoka opened this Issue Mar 20, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@yasuoka
Contributor

yasuoka commented Mar 20, 2014

If evdns has multiple waiting requests and evdns_shutdown() is
called, it releases only one request and leaks the other requests. This
sometimes causes SIGSEGV.

Test program: evdns_test.c

Test result on OpenBSD 5.4 amd64 + libevent-release-2.0.21-stable

% env MALLOC_OPTIONS=J ./evdns_test
periodic(1)
periodic(2)
on_resolved(result[0]=68)
periodic(3)
periodic(4)
periodic(5)
periodic(6)
Segmentation fault (core dumped)
% 

Patch to fix: evdns_shutdown.diff

Test result on OpenBSD 5.4 amd64 + libevent -current + patch

% env MALLOC_OPTIONS=J ./evdns_test
[msg] Nameserver 127.0.0.2:53 has failed: Network is unreachable
[msg] All nameservers have failed
periodic(1)
periodic(2)
on_resolved(result[1]=68)
on_resolved(result[0]=68)
periodic(3)
periodic(4)
periodic(5)
periodic(6)
periodic(7)
periodic(8)
% 

nmathewson added a commit that referenced this issue Mar 21, 2014

Fix a crash in evdns related to shutting down evdns
Patch from YASUOKA Masahiko; fix for libevent github issue #113.
@nmathewson

This comment has been minimized.

Show comment
Hide comment
@nmathewson

nmathewson Mar 21, 2014

Member

This looks okay to me. Merged in 2.0 and 2.1.

Member

nmathewson commented Mar 21, 2014

This looks okay to me. Merged in 2.0 and 2.1.

@nmathewson nmathewson closed this Mar 21, 2014

@yasuoka

This comment has been minimized.

Show comment
Hide comment
@yasuoka

yasuoka Mar 22, 2014

Contributor

Thanks!

Contributor

yasuoka commented Mar 22, 2014

Thanks!

@yasuoka

This comment has been minimized.

Show comment
Hide comment
@yasuoka

yasuoka Mar 24, 2014

Contributor

Sorry, I'd like you to reopen this issue since the previous patch fix the problem partially.

evdns has probe requests internally, those requests also had remained after evdns_shutdown() and they cause SIGSEGV. I think evdns_shutdown() should cancel those request.

New test program: evdns_test2.c

Test result on OpenBSD 5.4 amd64 + libevent -current(86665a5)

% env MALLOC_OPTIONS=J ./evdns_test2
[msg] Nameserver 127.0.0.1:53 has failed: request timed out.
[msg] All nameservers have failed
on_resolved()
on_resolved()
on_timeout() calling evdns_shutdown(1)
Bus error (core dumped)
%

Patch to fix: evdns_shutdown2.diff

Test result on OpenBSD 5.4 amd64 + libevent -current(86665a5) + patch

% env MALLOC_OPTIONS=J ./evdns_test2
[msg] Nameserver 127.0.0.1:53 has failed: request timed out.
[msg] All nameservers have failed
on_resolved()
on_resolved()
on_timeout() calling evdns_shutdown(1)
%
Contributor

yasuoka commented Mar 24, 2014

Sorry, I'd like you to reopen this issue since the previous patch fix the problem partially.

evdns has probe requests internally, those requests also had remained after evdns_shutdown() and they cause SIGSEGV. I think evdns_shutdown() should cancel those request.

New test program: evdns_test2.c

Test result on OpenBSD 5.4 amd64 + libevent -current(86665a5)

% env MALLOC_OPTIONS=J ./evdns_test2
[msg] Nameserver 127.0.0.1:53 has failed: request timed out.
[msg] All nameservers have failed
on_resolved()
on_resolved()
on_timeout() calling evdns_shutdown(1)
Bus error (core dumped)
%

Patch to fix: evdns_shutdown2.diff

Test result on OpenBSD 5.4 amd64 + libevent -current(86665a5) + patch

% env MALLOC_OPTIONS=J ./evdns_test2
[msg] Nameserver 127.0.0.1:53 has failed: request timed out.
[msg] All nameservers have failed
on_resolved()
on_resolved()
on_timeout() calling evdns_shutdown(1)
%

nmathewson added a commit that referenced this issue Mar 26, 2014

Fix a crash in evdns related to shutting down evdns
(Improved version to deal correctly with probe requests)

Patch from YASUOKA Masahiko; fix for libevent github issue #113.
@nmathewson

This comment has been minimized.

Show comment
Hide comment
@nmathewson

nmathewson Mar 26, 2014

Member

Merged that; thanks.

Member

nmathewson commented Mar 26, 2014

Merged that; thanks.

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