ayuseleznev 4da9f87ccb evdns: fix a crash when evdns_base with waiting requests is freed
Fix undefined behaviour and application crash that might take
place in some rare cases after calling evdns_base_free when
there are requests in the waiting queue.

Current cleanup procedure in evdns_base_free_and_unlock
function includes 2 steps:
1. Finish all inflight requests.
2. Finish all waiting requests.
During the first step we iterate over each list in req_heads
structure and finish all requests in these lists. With current
logic finishing an inflight request (function request_finished)
removes it from the inflight requests container and forces
a wating connection to be sent (by calling
evdns_requests_pump_waiting_queue). When these new requests are
sent it is possible that they will be inserted to the list in
req_heads that we've already cleaned.
So in some cases container of the inflight requests is not empty
after this procedure and some requests are not finished and
deleted. When timeouts for these requests expire
evdns_request_timeout_callback is called but corresponding
evdns_base has been already deleted which causes undefined
behaviour and possible applicaton crash.

It is interesting to note that in old versions of libevent such
situation was not possible. This bug was introduced by the commit
14f84bbdc77d90b1d936076661443cdbf516c593. Before this commit
nameservers were deleted before finishing the requests. Therefore
it was not possible that requests from the waiting queue be sent
while we finish the inflight requests.
2020-02-28 15:06:24 +03:00
2020-01-27 01:50:13 +03:00
2016-10-05 15:47:46 +03:00
2019-11-14 18:28:31 +08:00
2016-10-05 15:47:46 +03:00
2016-10-31 22:37:56 +03:00
2017-01-26 02:36:00 +03:00
2019-02-28 17:48:10 -08:00
2019-02-28 17:48:10 -08:00
2016-10-05 15:51:40 +03:00
2019-03-11 20:11:44 +03:00
2019-08-29 23:08:12 +03:00
2018-12-16 00:51:14 +03:00
2006-10-15 21:41:56 +00:00
2018-08-02 02:50:48 +03:00
2015-08-25 19:15:50 +03:00
2019-04-01 02:42:07 +03:00
2019-11-06 21:07:16 +03:00
2020-01-13 00:50:14 +03:00
2019-10-04 01:30:39 +02:00
2019-11-06 21:44:30 +03:00
2020-01-21 22:03:37 -08:00
2012-04-09 11:30:46 -04:00
2013-02-07 17:55:36 -08:00
2017-01-26 02:36:00 +03:00
2019-04-11 22:48:01 +03:00

libevent logo

Appveyor Win32 Build Status Travis Build Status Coverage Status Join the chat at https://gitter.im/libevent/libevent doxygen

1. BUILDING AND INSTALLATION

Autoconf

$ ./configure
$ make
$ make verify   # (optional)
$ sudo make install

See Documentation/Building#Autoconf for more information

CMake (Windows)

Install CMake: https://www.cmake.org

$ md build && cd build
$ cmake -G "Visual Studio 10" ..   # Or use any generator you want to use. Run cmake --help for a list
$ cmake --build . --config Release # Or "start libevent.sln" and build with menu in Visual Studio.

See Documentation/Building#Building on Windows for more information

CMake (Unix)

$ mkdir build && cd build
$ cmake ..     # Default to Unix Makefiles.
$ make
$ make verify  # (optional)

See Documentation/Building#Building on Unix (With CMake) for more information

Package Managers

You can download and install libevent using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install libevent

The libevent port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

2. USEFUL LINKS:

For the latest released version of Libevent, see the official website at http://libevent.org/ .

There's a pretty good work-in-progress manual up at http://www.wangafu.net/~nickm/libevent-book/ .

For the latest development versions of Libevent, access our Git repository via

$ git clone https://github.com/libevent/libevent.git

You can browse the git repository online at:

https://github.com/libevent/libevent

To report bugs, issues, or ask for new features:

Patches: https://github.com/libevent/libevent/pulls

OK, those are not really patches. You fork, modify, and hit the "Create Pull Request" button. You can still submit normal git patches via the mailing list.

Bugs, Features [RFC], and Issues: https://github.com/libevent/libevent/issues

Or you can do it via the mailing list.

There's also a libevent-users mailing list for talking about Libevent use and development:

http://archives.seul.org/libevent/users/

3. ACKNOWLEDGMENTS

The following people have helped with suggestions, ideas, code or fixing bugs.

Description
Languages
C 87%
Roff 3.8%
CMake 3.6%
M4 2.5%
Python 2.2%
Other 0.9%