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

Zabbix components treat all library interfaces and libraries as local modules

XMLWordPrintable

      The Zabbix component - the agent, proxy and server applications, and libraries - source code modules treat library and module interfaces as local.

      The C programming language, in all its standardized forms (ISO/IEC 9899:1990 (aka C89, aka C90, aka ANSI C), ISO/IEC 9899:1999 (aka C99), ISO/IEC 9899:2011 (aka C11), ISO/IEC 9899:2018 (aka C17)), in regards to source file inclusion, prescribe two forms for source file inclusion. Specifically

      § 6.10.2.2:

      # include <h-char-sequence> new-line

      § 6.10.2.3:

      # include "q-char-sequence" new-line

      Note: section references used refer to items as they appear in the ISO/IEC 9899:2011 version.

      The standard, in all its iterations, has always described the semantics of file look-up for this directive as implementation defined. However, it has been a long established practice of using the angle-brace form for look-up in standard system directories and the double-quote form for lookup in paths relative to the location of the current file (the translation unit). GCC, as the most venerable compiler system, describes this here.

      The standards have also always noted the following, regarding the search:

      If this search is not supported, or if the search fails, the directive is reprocessed as if it read

      # include <h-char-sequence> new-line

      with the identical contained sequence (including > characters, if any) from the original directive.

      In the former, angle-brace, form, the list of default search directories is usually supplemented via the -I pre-processor option flag (gcc, clang).

      In the case of Zabbix, all source code files exclusively rely on the second, double-quote, form of source file inclusion, which happens to work due to the pre-processor falling back onto searching for the headers in include the system include directories (the list of which we supplement with the public library interface directory at /include, at the project root directory).

      This is generally bad practice, as the two forms are immediate indicators of the locality of requested functionality for the developer, strain the pre-processor during processing, by making it search for files in the translation units directory (where they are unlikely to be found most of the time), as well as create the opportunity for build failures due to Zabbix header file name collisions in the case the look-up order is ever changed.

      The correct course of action should be switching all includes of public interfaces to using the angle-brace form of source file inclusion, as is done with any other external library interface.

      Additionally, for products producing a large number of interfaces, these interfaces are generally namespaced in the header directory. Zabbix fits this criteria. The proposition is to strip the existing zbx prefix from the interface file names, and use zabbix as the namespace.

            palivoda Rostislav Palivoda
            jlambda Juris Lambda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: