Skip to content

Conversation

@ellert
Copy link
Contributor

@ellert ellert commented Dec 1, 2024

The format for some size_t variables were recently changed from %d to %llu. This fixed a problem on 64 bit architectures, since there size_t is 64 bits wide and %d is the format for a 32 bit type and %llu is the format for a 64 bit type. However, this change introduced a regression on 32 bit architectures where size_t is 32 bits wide.

This change caused some of the tests to fail with a segmentation fault on the Debian armhf architecture:

The following tests FAILED:
108 - XRootD::noauth::test (Failed)
111 - XRootD::host::test (Failed)
114 - XRootD::unix::test (Failed)
117 - XRootD::sss::test (Failed)
120 - XRootD::http::test (Failed)

This first commit adds a type cast so that the new format works for all architectures.

It is possible to get warnings from the compilers for bad format strings that don't match the types of the variables by using atribute((format)). The second commit adds this attribute to the logging routines in the client library.

The third commit fixes the errors from this type checking produced by the compiler for the master branch.

The fourth commit contains additional fixes for the devel branch relared to the "timeout uses time_t" change. This commit should no go to mastar untill that change does.

The first three commits should go to master.

@ellert ellert force-pushed the format-regression branch from ae9b35c to e6f75e2 Compare December 2, 2024 19:24
@ellert ellert changed the title Use correct format for size_t Add type checking to format strings used in the client library logging routines and fix the errors that it triggers Dec 2, 2024
@amadio amadio force-pushed the devel branch 3 times, most recently from bf0b7bc to d54785d Compare December 18, 2024 16:12
@ellert ellert force-pushed the format-regression branch from ae68ace to dd5f2e2 Compare January 21, 2025 18:44
@ellert ellert changed the base branch from devel to master January 21, 2025 18:44
@ellert
Copy link
Contributor Author

ellert commented Jan 21, 2025

The fourth commit (related to changes in the devel branch) was split out to a separate PR #2412.
This PR was then rebased to use the master branchas base.

@ellert ellert force-pushed the format-regression branch from dd5f2e2 to ec098cb Compare January 26, 2025 07:49
@abh3
Copy link
Member

abh3 commented Jan 27, 2025

I would be fine with it but when you look at the documentation many times it does not list %z making you wonder whether or not it's supported. Given that you really don't need to use %z since the replacement is a trivial type cast,; we can avoid all of this uncertainty here by using that approach.

The format for some size_t variables were recently changed from %d to
%llu. This fixed a problem on 64 bit architectures, since there size_t
is 64 bits wide and %d is the format for a 32 bit type and %llu is the
format for a 64 bit type. However, this change introduced a regression
on 32 bit architectures where size_t is 32 bits wide.

This change caused some of the tests to fail with a segmentation fault
on the Debian armhf architecture:

The following tests FAILED:
	108 - XRootD::noauth::test (Failed)
	111 - XRootD::host::test (Failed)
	114 - XRootD::unix::test (Failed)
	117 - XRootD::sss::test (Failed)
	120 - XRootD::http::test (Failed)

This commit changes these format strings to use %zu for size_t values.
so that the compiler can do type checking for format strings
@ellert ellert force-pushed the format-regression branch from ec098cb to acab969 Compare January 27, 2025 23:25
@amadio amadio added this to the 5.7.3 milestone Jan 28, 2025
@amadio amadio merged commit 4169a0a into xrootd:master Jan 28, 2025
9 checks passed
@ellert ellert deleted the format-regression branch January 28, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants