TSAN uncovered cases where we were reading values in the transaction
thread that were set on the main thread and were unprotected by lock. In
practice this is unlikely to cause an harm, but it's good to keep TSAN
clean for when there are real issues.
This unblocks nanopb changes proposed in #4264.
This upgrades everything in the gRPC constellation of dependencies to match gRPC at 1.28:
* gRPC to 1.28.0 (note that gRPC 1.28.1, while released, is a fix for just the python binding and there's no gRPC-C++ CocoaPod at that version)
* Abseil to 20200225 (as of gRPC 1.27 this is now a gRPC dependency too; there's a later patch but gRPC doesn't use it yet)
* Protobuf C++ to 3.11.4 (only used for testing in Firestore)
* C-Ares to 1.15.0
* BoringSSL to match (no change between gRPC 1.27.0 and 1.28.0)
Also, this disables CFStream-based transport on Apple platforms. This works around b/133182964, wherein CFStream will occasionally fail to raise a has-bytes-available events, causing Firestore to appear to hang.
* Fix unused variable warnings
These are now exposed because libprotobuf is no longer polluting the
compiler command-line with -Wno-unused-parameter.
* Convert (void)var to __unused where possible
* Fix use after move in LevelDbPersistenceForTesting
* Fix size-related errors when compiling in 32-bit mode
* Fix test-only memory leaks
* Fix test-only memory leaks
* Prevent spec tests from appearing to leak
The spec tests aren't actually leaking, but they accumulate enough
garbage without clearing the autorelease pool that Instruments
complains.
* Avoid temporaries in methods that @throw
ARC does not release temporaries when an Objective-C exception is
thrown. Use C++ equivalents directly to avoid leaks as detected by
Instruments.
* Fix memory leak in acknowledge mutation
Any previous value must be freed before the next one is assigned.
* Manually implement assignment operators in ByteString
The single by-value implementation wasn't preventing the compiler
generated standard versions from being generated which was causing
leaks.
* Prevent leaking GrpcCompletions that complete after Shutdown
After shutdown, the AsyncQueue silently drops Enqueue requests which
prevents these blocks from being deleted.
* Avoid racing with enqueued operations
It's possible for the Executor to immediately execute the given block,
at which point the block might observe the async queue in a
not-shutting-down state.
This includes fixes for:
* All the field escaping tests
* testCanWriteVeryLargeBatches
* testWritesWithIndirectlyNestedArraysSucceed
All tests now pass. I've left isRunningAgainstEmulator in the source
even though there are now no callers.
* Move all Firestore files to Objective-C++
* Update project file references
* Don't use module imports from Objective-C++
* Use extern "C" for C-accessible globals
* Work around more stringent type checking in Objective-C++
* NSMutableDictionary ivars aren't implicitly casted to NSDictionary
* FSTMaybeDocument callback can't be passed a function that accepts
FSTDocument
* NSComparisonResult can't be multiplied by -1 without casting
* Add a #include <inttypes.h> where needed
* Avoid using C++ keywords as variables
* Remove #if __cplusplus guards