-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pal: platform abstraction layer and strerror_r(3) wrapper #8390
Open
altimeter-130ft
wants to merge
13
commits into
fluent:master
Choose a base branch
from
altimeter-130ft:topic-pal-strerror_r-wrapper-github-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
pal: platform abstraction layer and strerror_r(3) wrapper #8390
altimeter-130ft
wants to merge
13
commits into
fluent:master
from
altimeter-130ft:topic-pal-strerror_r-wrapper-github-pr
+224
−5
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Glibc has the different return type and return value semantics from POSIX.1-2001 on strerror_r(3). Also, the glibc strerror_r(3) may return the pointer different from the given one. The difference will be absorbed by the platform abstraction layer, committed separately. Signed-off-by: Seigo Tanimura <[email protected]>
The signature is that of POSIX.1-2001. If the returned string is not in the supplied buffer, copy the string to it. Signed-off-by: Seigo Tanimura <[email protected]>
Actually, only the external behaviour is tested; there is no support for the mock of the library functions in general. Signed-off-by: Seigo Tanimura <[email protected]>
flb_strerror_r() always terminates the string buffer by NUL. Signed-off-by: Seigo Tanimura <[email protected]>
flb_strerror_r() always terminates the string buffer by NUL. Signed-off-by: Seigo Tanimura <[email protected]>
flb_strerror_r() always returns the string into the supplied buffer. Signed-off-by: Seigo Tanimura <[email protected]>
3 tasks
altimeter-130ft
requested review from
fujimotos,
niedbalski,
patrick-stephens,
celalettin1286,
edsiper,
leonardo-albertovich and
koleini
as code owners
January 18, 2024 15:29
It is the C11 edition of strerror_r(3), provided by MSVC. Signed-off-by: Seigo Tanimura <[email protected]>
Signed-off-by: Seigo Tanimura <[email protected]>
Signed-off-by: Seigo Tanimura <[email protected]>
…r(3). It is misleading that the return type of strerror_s(3) is errno_t, while its semantics is the int a la the Unix system calls. While I am here, fix the unintended tabs. Signed-off-by: Seigo Tanimura <[email protected]>
Such the condition seems not treated as a runtime constraint violation. The best solution is hence to guarantee that the zero status means that a NUL-terminated string is returned. Signed-off-by: Seigo Tanimura <[email protected]>
Strerror_s(3) does not detect the short buffer, and that cannot be covered by pal. Signed-off-by: Seigo Tanimura <[email protected]>
Signed-off-by: Seigo Tanimura <[email protected]>
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. |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is for the following changes:
pal
module, the platform abstraction layer.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 ofstrerror_r(3)
intopal
, the new core module dedicated to encapsulate the platform dependency found on the common external features. The goal ofpal
is similar to theAC_LIBOBJ()
macro of GNU Autoconf, except thatpal
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 underlib
must not call them, in order to keep their independency.pal
Source Filessrc/flb_pal.c
include/fluent-bit/flb_pal.h
pal
Internal Test Filestests/internal/pal.c
New
pal
Functionint flb_strerror_r(int errnum, char *buf, size_t buflen);
The wrapper of
strerror_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()
CallersThe
strerror_r(3)
calls in the following files have been converted toflb_strerror_r()
:src/flb_io.c
src/flb_log.c
src/flb_network.c
Tested Environments
strerror_r(3)
standard: glibc)strerror_r(3)
standard: POSIX.1-2001)Testing
N/A
Example configuration file for the changeThe issue does not depend on a specific configuration.
Debug log output from testing the change
Attached Valgrind output that shows no leaks or memory corruption was found
Test Results
fluent-bit-cmake-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.log
The
cmake
log.fluent-bit-make-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.log
The
make
log.fluent-bit-ctest-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.log
The
ctest
log.fluent-bit-ctest-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2-LastTest.log
The
LastTest.log
file out ofctest
.fluent-bit-valgrind-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.log
The
valgrind --leak-check=full
log.No memory leak happened.
gcov-tests-topic-pal-strerror_r-wrapper-github-pr-debian_x86_64_12_2.tar.xz
The
lcov
coverage report.strerror_r(3)
never returningNULL
?fluent-bit-cmake-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.log
The
cmake
log.fluent-bit-make-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.log
The
make
log.fluent-bit-ctest-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.log
The
ctest
log.fluent-bit-ctest-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release-LastTest.log
The
LastTest.log
file out ofctest
.fluent-bit-valgrind-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.log
The
valgrind --leak-check=full
log.llvm-cov-tests-topic-pal-strerror_r-wrapper-freebsd_amd64_14_0_release.tar.xz
The LLVM coverage report.
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
N/A
Run local packaging test showing all targets (including any new ones) build.N/A
Setok-package-test
label to test for all targets (requires maintainer to do).Packaging is not affected.
Documentation
?
Documentation required for this featureThe
pal
paragraph inDEVELOPER_GUIDE.md
?Backporting
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.