Skip to content
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

More compiler warnings, and sanitizers, in CMake builds #2138

Merged
merged 12 commits into from
Oct 2, 2024
Merged

Conversation

snej
Copy link
Collaborator

@snej snej commented Sep 13, 2024

Added new CMake options:

  • LITECORE_WARNINGS_HARDCORE enables all compiler warnings except for a few dozen that are too onerous, plus -Werror.
  • LITECORE_SANITIZE enables the Clang Address and UB sanitizers.

Currently these are only supported in Clang builds, and ignored with other compilers. They are propagated to Fleece (see couchbase/fleece#239)

Also made source changes to fix some new warnings produced by this.

NOTE to reviewers: It's probably clearest if you review the commits individually rather than looking at the "Files changed" tab. Most of the diffs come from the first commit 343bfac which is simply replacing static inline with inline in standalone functions in header files, and from 2356d46 which is a lot of independent little changes fixing compiler warnings.

An inline function (not method!) in a header file shouldn't be
declared `static` or it'll be copied into every compilation unit
that uses it.
@snej snej force-pushed the warnings branch 6 times, most recently from 66ad5fc to 529d81a Compare September 17, 2024 22:03
and removed Channel.cc which was empty
It's timing-sensitive, and in particular has started failing now
that sanitizers are enabled. All it seems to do is check that an
unsorted query is faster than a sorted one.
1. The replicator's pending-documents API would leak a Checkpointer
   object on each call, because it was allocated with a bare `new`
   and not deleted in the destructor.
2. The query translator would leak a locale string when parsing a
   COLLATE expression, because the CollateNode class contained a
   Collation object, which wasn't freed by the arena allocator.
3. c4db_collectionNames and c4db_scopeNames would leak Fleece mutable
   arrays if the db is closed, due to an exception being thrown.
- Turned off -Wformat in Linux builds since it causes warnings
  everywhere we pass int64_t through a printf-type function, which
  is not actually a problem.
- Suppressed a false "control reaches end of non-void function" in
  ExprNodes.cc.
- Fixed a few places in BLIP where values of different enum types are
  or-ed together.
@cbl-bot
Copy link

cbl-bot commented Sep 19, 2024

Code Coverage Results:

Type Percentage
branches 65.93
functions 78.47
instantiations 70.92
lines 77.6
regions 73.06

It would be cleaner to fix this by editing c4LocalReplicator.hh
in the couchbase-lite-core-EE repo, but that would involve more work
wrestling with Git repos.
@jianminzhao
Copy link
Contributor

With this PR, will it compile with the master branch of fleece?

Copy link
Member

@borrrden borrrden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok code wise but fleece needs to be merged first and then this PR updated to point to the master branch.

@jianminzhao
Copy link
Contributor

@borrrden the fleece reference actually points to a commit that has same content as master (via git diff ..master). I changed it to be actual master branch.

Copy link
Member

@borrrden borrrden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blackduck check is a false positive because of source edits (though at what point does it become our own forked product and not a third party one in terms of security scan...)

@jianminzhao jianminzhao merged commit d53db2e into master Oct 2, 2024
7 of 8 checks passed
@jianminzhao jianminzhao deleted the warnings branch October 2, 2024 23:59
jianminzhao added a commit that referenced this pull request Oct 8, 2024
CBL-6148: Update Replication Protocol for 4.0 (#2140)
683737c Fixed incorrect SchemaVersion::Current (#2153)
44a0d4a Make test logs readable in CLion (#2143)
d53db2e More compiler warnings, and sanitizers, in CMake builds (#2138)
23441ce CBL-6288: Disable Replication tests in Actions. (#2151)
56f7749 Fixed UB when a CollectionChangeObserver deletes itself in its callback (#2123)
6eb8ec8 Pick up latest from the master branch of fleece. (#2145)
a177348 QueryTranslator: Implemented predictive index support (#2141)
CBL-5616: Update SG docker version (again)
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.

4 participants