pal: platform abstraction layer and strerror_r(3) wrapper
This PR is for the following changes:
- Introduce the
palmodule, the platform abstraction layer. - Add
flb_strerror_r(), the wrapper ofstrerror_r(3).
Fixed Issue
#8379
Background
The strerror_r(3) implementations of glibc and POSIX.1-2001 have the different signatures and usages, which causes a build error and/or an unexpected behaviour.
Please refer to Issue #8379 for the detailed analysis.
Changes
This fix implements flb_strerror_r(), the POSIX.1-2001-compliant wrapper of strerror_r(3) into pal, the new core module dedicated to encapsulate the platform dependency found on the common external features. The goal of pal is similar to the AC_LIBOBJ() macro of GNU Autoconf, except that pal holds all wrapper functions in a single source.
The wrapper functions in pal are intended for the Fluent Bit core and plugins only. The third-party libraries under lib must not call them, in order to keep their independency.
pal Source Files
-
src/flb_pal.c -
include/fluent-bit/flb_pal.h
pal Internal Test Files
-
tests/internal/pal.c
New pal Function
-
int flb_strerror_r(int errnum, char *buf, size_t buflen);The wrapper ofstrerror_r(3)with the signature and semantics of POSIX.1-2001. Available ifstrerror_r(3)exists in the platform, regardless from its implementation.
flb_strerror_r() Callers
The strerror_r(3) calls in the following files have been converted to flb_strerror_r():
-
src/flb_io.c -
src/flb_log.c -
src/flb_network.c
Tested Environments
- Debian x86_64 12.2 (
strerror_r(3)standard: glibc) - FreeBSD/amd64 14.0-RELEASE (
strerror_r(3)standard: POSIX.1-2001)- fluent/fluent-bit/pull/8376 included for the coverage report.
Testing
-
N/AExample configuration file for the change The issue does not depend on a specific configuration. -
[x] Debug log output from testing the change
-
[x] Attached Valgrind output that shows no leaks or memory corruption was found
Test Results
- Debian x86_64 12.2: logs-fluent-bit-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.zip
-
fluent-bit-cmake-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.logThecmakelog. -
fluent-bit-make-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.logThemakelog. -
fluent-bit-ctest-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.logThectestlog. -
fluent-bit-ctest-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2-LastTest.logTheLastTest.logfile out ofctest. -
fluent-bit-valgrind-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.logThevalgrind --leak-check=fulllog. No memory leak happened. -
gcov-tests-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.tar.xzThelcovcoverage report.- The new code has been covered except for one.
- Can we depend on the glibc
strerror_r(3)never returningNULL?
- Can we depend on the glibc
- The new code has been covered except for one.
-
- FreeBSD/amd64 14.0-RELEASE: logs-fluent-bit-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.zip
-
fluent-bit-cmake-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.logThecmakelog. -
fluent-bit-make-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.logThemakelog. -
fluent-bit-ctest-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.logThectestlog. -
fluent-bit-ctest-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release-LastTest.logTheLastTest.logfile out ofctest. -
fluent-bit-valgrind-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.logThevalgrind --leak-check=fulllog.- The coverage is disabled because of the Valgrind problem that makes an assertion failure.
- Many conditional jumps or moves on uninitialised value.
- These are the false errors; no conditional instructions have been found out of the codewalk.
- 3 blocks are still reachable with flb_strerror_r().
- These are for the NLS message catalogue, read only once and staying until the process exits.
- The rest of the leaks do not involve the Fluent Bit implementation.
-
llvm-cov-tests-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.tar.xzThe LLVM coverage report.- The new code has been covered.
-
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
-
N/ARun local packaging test showing all targets (including any new ones) build. -
N/ASetok-package-testlabel to test for all targets (requires maintainer to do). Packaging is not affected.
Documentation
-
?Documentation required for this feature Thepalparagraph inDEVELOPER_GUIDE.md?
Backporting
- [x] Backport to latest stable release. This PR is the fix to a build breakage.
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.