Repository navigation
Milestone 7: widen the CI matrix, add the analysers - #3
Merged
Merged
Conversation
Milestone 7.
The matrix covered the two families the project promises to support, in
the two configurations that matter for a header-only library. It now
covers the ABI as well: a 32-bit build runs the whole suite where
pointers, size_t and long are half the width, which is where a
hand-rolled struct ABI or a 64-bit-only conversion would show up, and
macOS runs it on a libc that is neither glibc nor Winsock.
The sanitizer job becomes a small matrix over AddressSanitizer +
UndefinedBehaviorSanitizer and ThreadSanitizer, because they answer
different questions and the second one now has something to look at: the
mock NTP server is a real thread with a real socket. NTP_LITE_SANITIZE
therefore takes a list as well as the on/off spelling - ON still means
address,undefined, and "-DNTP_LITE_SANITIZE=thread" means what it says.
The two cannot be combined, so the combination is refused at configure
time rather than producing a binary that dies before main.
Two analysers then run over the library, a different one from the
compiler and a different one from each other: clang-tidy, with its check
list written out in .clang-tidy rather than assembled from wildcards, so
the job cannot start failing because a runner upgraded its tools; and
cppcheck, which has different blind spots. Both are pointed at
src/ntplite_c.cpp and the generated header-hygiene translation units, one
header at a time - that is the whole of the code a consumer compiles, in
the smallest units that compile it, which keeps the run quick and keeps
every finding where it can be acted on rather than among the tests.
GCC's -fanalyzer was tried first and left out. On gcc 11.4 it reports a
null dereference inside libstdc++'s vector growth path
("operator new(136, __p) could be NULL: unchecked value from (39)"),
reached from a perfectly ordinary push_back; it is the analyser's known
trouble with the standard library, not a finding. clang-tidy's analyser
covers the same ground and does not do this.
A coverage job reports with gcovr and uploads the result, and is
deliberately not a gate: a line count is a poor reason to fail a build,
and a job that fails because a refactor moved a branch around teaches
nobody anything.
scripts/remote_build.ps1 grows -SanitizerList and
-ExtraConfigureArguments so a configuration can be tried on the Linux
development host before it earns a job of its own - which is how the
sanitizer list and the refusal above were checked.
Linux and Winsock let sendto() carry a destination on a socket that is already connected; the BSD-derived stacks - macOS among them - fail the call with EISCONN instead. The client connects before it sends, so on macOS every query died as a network error one line before its first datagram left the process: the mock server saw no requests, the external Python server saw none either, and the silent-server case returned in 0.03 s without a single attempt. send_to() now sends to the peer the kernel already holds when there is one, and keeps handing the address over while there is not, which is the only case where the address can mean anything. Nothing but the macos job could have noticed, because only that socket stack refuses the second opinion; it is new in this milestone and said so on its first run.
Four test cases send to a peer that never answers, then count what the peer received. They counted the instant the client stopped waiting, which races the delivery of its last request: the client sends, the kernel takes the datagram, and the peer's queue is filled in later - on the BSD-derived stacks by a kernel thread that runs when it runs. Linux and Windows deliver loopback packets inside the send call, so the race had been invisible for the life of the project. drain() now reads until nothing has arrived for half a second, and says why. What the client promises is asserted where it is knowable - the attempt count - and the wire now only has to agree.
bugprone-signed-char-misuse reads `out.poll = source.poll` - a signed 8 bit exponent widened into the int the C struct carries - as the character classification bug it usually is. It is not one here: Poll and Precision are log2-second exponents and a negative Precision is ordinary, so the sign has to survive. The widening now goes through unsigned char, which is the form the check suggests, leaves one reading of the value, and says out loud that these are arithmetic bits rather than a character. Same numbers, no finding.
This file contains hidden or 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
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.
Widens the CI matrix (32-bit, macOS), splits the sanitizers into ASan+UBSan and TSan, and adds clang-tidy and cppcheck over the library. Draft until the new jobs are green.