Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-25321

FTBFS on OpenBSD 7.5 (server, proxy) with libevent

XMLWordPrintable

    • S24-W42/43, S24-W44/45, S24-W46/47, S24-W48/49
    • 1

      The Zabbix server and proxy unconditionally rely on libevent (or compatible interface providing implementation).

      libevent has two APIs, a legacy one and the reworked one which resulted in libevent 2.x being released (for the purposes of this report, I'll be referring to the latter as libevent2).

      Both libevent2 and other event library implementations (such as libev) provide a compatibility layer for applications written for the legacy interface to run with the newer or incompatible implementations.

      We are dependent on the new API, as we explicitly test and use interfaces provided by it[1][2][3], while we expect that the compatability header is always present[4][5][6].

      OpenBSD ship the legacy libevent library, in the base system, while libevent2 is available in ports.

      When configuring a build of the server and/or proxy against the system libevent, the detection test fails due to the test code including headers provided by libevent2 (as in [1]):

      [..]
      configure:12636: checking for libevent support
      configure:12686: cc -o conftest -g -O2 -I/usr/include  -rdynamic  -L/usr/lib conftest.c -lpthread -lkvm -lm -lexecinfo   -levent_core -levent_pthreads >&5
      conftest.c:124:10: fatal error: 'event2/thread.h' file not found
      #include <event2/thread.h>
               ^~~~~~~~~~~~~~~~~
      1 error generated.
      configure:12686: $? = 1
      configure: failed program was:
      [..]
      

      When configuring a build of the server and/or proxy against libevent2, configure succeeds at the test, but building fails:

      [..]
      Making all in zbxasyncpoller
        CC       libzbxasyncpoller_a-asyncpoller.o
      In file included from asyncpoller.c:15:
      ../../../include/zbxasyncpoller.h:54:64: warning: declaration of 'struct evdns_base' will not be visible outside of this function [-Wvisibility]
      void                    zbx_async_poller_add_task(struct event_base *ev, struct evdns_base *dnsbase, const char *addr,
                                                                                      ^
      ../../../include/zbxasyncpoller.h:59:51: warning: declaration of 'struct evdns_base' will not be visible outside of this function [-Wvisibility]
      void                    zbx_async_dns_update_host_addresses(struct evdns_base *dnsbase);
                                                                         ^
      In file included from asyncpoller.c:21:
      /usr/local/include/event2/event.h:382:13: error: conflicting types for 'event_base_get_method'
      const char *event_base_get_method(const struct event_base *);
                  ^
      /usr/include/event.h:300:13: note: previous declaration is here
      const char *event_base_get_method(struct event_base *);
                  ^
      In file included from asyncpoller.c:21:
      /usr/local/include/event2/event.h:711:9: warning: '_EVENT_LOG_DEBUG' macro redefined [-Wmacro-redefined]
      #define _EVENT_LOG_DEBUG EVENT_LOG_DEBUG
              ^
      /usr/include/event.h:314:9: note: previous definition is here
      #define _EVENT_LOG_DEBUG 0
              ^
      In file included from asyncpoller.c:21:
      /usr/local/include/event2/event.h:712:9: warning: '_EVENT_LOG_MSG' macro redefined [-Wmacro-redefined]
      #define _EVENT_LOG_MSG EVENT_LOG_MSG
              ^
      [..]
      

      The reason for this is twofold. The first is a missing include in the include/zbxasyncpoller.h header that defines the evdns_base type, while the header declares prototypes containing this type in their signatures.

      The other is due to the mixing of the include file names. In the above example, the asyncpoller.c module includes zbxasyncpoller.h first, which in turn includes event.h, thus transitively exposing the headers contents to the module, while the module itself never includes the header itself, and only includes the util.h and dns.h headers from the event2 namespace directory (as in [3]), which in turn, eventually include event2/event.h, which then colides with the header included by zbxasyncpoller.h as their guard symbols are different.

      This can all be fixed by (1) adding the missing include directive for the event2/dns.h header in include/zbxasyncpoller.h, and (2) switching all includes of the compatibility header to include event2/event.h instead.

      However, this exposes another issue, which is a failure at link-time to link the proxy and server executables, as no libevent link flags are ever passed to the linker.
      That should probably be a separate report, as working towards that requires the above described changes to expose.


      [1]: Zabbix m4/libevent.m4 macro package
      [2]: Zabbix src/libs/zbxpoller/checks_snmp.c
      [3]: Zabbix src/libs/zbxasyncpoller/asyncpoller.c
      [4]: Zabbix include/zbxasyncpoller.h
      [5]: Zabbix include/asynchttppoller.h
      [6]: Zabbix src/libs/zbxipcservice/ipservice.c

            jlambda Juris Lambda
            jlambda Juris Lambda
            Team C
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 0.75h
                0.75h