libevent used uninitialized on faulty code path

[warn] warning from libevent: event_add: event has no event_base set.

The modern libevent provides reentrant functions (base* parameter), but it still exposes the old interface and deprecated global state variables. Tor's tor_libevent_initialize() decides to use the new interface, and completely skips the old event_init() call which would initialize the global state.

In src/ocmmon/compat_libevent.h, the function tor_event_base_loopexit() is #ifdefed based on a configure variable called HAVE_EVENT_BASE_LOOPEXIT. If it's defined, it forwards to libevent, otherwise it expands to a helper function. This function calls one of the old interfaces that rely on global state.

The bug is that current src/win32/orconfig.h defines HAVE_EVENT2_EVENT_H but does not define HAVE_EVENT_BASE_LOOPEXIT. This causes the abovementioned code to skip initializing the old global libevent state, but then later ends up calling a function that depends on it.

Adding #define HAVE_EVENT_BASE_LOOPEXIT to orconfig.h fixes it.

Trac:
Username: ultramage