[BREAKGLASS] A private messenger for iOS. https://signal.org
Go to file
Michelle Linington bcb7eddb63 Fix issue with data migrations after a schema change
We're seeing crashes during this data migration step. We fail to init
the OWSUserProfile from the Row result returned from the SQLite fetch
request. It's likely we're indexing into an out-of-bounds index on Row.
(Row._checkIndex is inlined so we can't be sure)

GRDB caches the sqlite3_column_count during Row.init and uses that to
determine if a subscript access is out-of-bounds. From what I can tell
in an amateur reading of sqlite3.c, that just pulls the nResColumn from
the prepared statement. SQLite will determine the number of result
columns during statement prep, but the column count can change if the
table schema changes:

> If the database schema changes, instead of returning SQLITE_SCHEMA as
  it always used to do, sqlite3_step() will automatically recompile the
  SQL statement and try to run it again. As many as
  SQLITE_MAX_SCHEMA_RETRY retries will occur before sqlite3_step() gives
  up and returns an error.

We're nesting a deferred read transaction inside of our data migration's
immediate transaction. This read is using a different sqlite connection
that the connection performing our migrations. So its understanding of
the schema is stale and because it's in a deferred transaction it won't
figure this out until we call _step().

Once we call _step(), sqlite will realize that the table schema has
changed and recompile the prepared statement while opening the
deferred transaction. After this, the sqlite_column_count is correct.
But Row still has the incorrect value cached from before the schema was
resolved.

So by the time we try and init our OWSUserProfile, Row falsely asserts
that we're indexing beyond the column count by comparing against a stale
version of the column count.

The fix:
Rework the data migration to avoid nesting a deferred read transaction.
This is incorrect behavior. Now that our read is using our already open
write transaction with the same connection handle, it's understanding of
the schema is up-to-date during statement prep. So Row.init grabs the
current column count.
2021-09-30 13:00:26 -07:00
.github Fix github actions 2021-08-18 16:40:05 -07:00
fastlane Update l10n strings. 2021-09-27 19:24:23 -03:00
NotificationServiceExtension "Bump build to 5.21.2.1." (Internal) 2021-09-30 14:04:39 -03:00
Pods@0f148ca373 Update Cocoapods. 2021-09-27 19:07:12 -03:00
Scripts Update copyright dates in SDS codegen 2021-09-24 10:30:09 -03:00
Signal Aggressively clear earlyRing flag 2021-09-30 12:57:41 -07:00
Signal.xcodeproj Apply design feedback. 2021-09-09 12:45:38 -03:00
Signal.xcworkspace Update workspace settings to use modern build system. Update Podfile to strip VALID_ARCHS flag from generated target xcconfig (deprecated in Xcode 12) 2021-06-17 14:29:14 -07:00
SignalMessaging Fix issue with data migrations after a schema change 2021-09-30 13:00:26 -07:00
SignalServiceKit Fix issue with data migrations after a schema change 2021-09-30 13:00:26 -07:00
SignalShareExtension "Bump build to 5.21.2.1." (Internal) 2021-09-30 14:04:39 -03:00
ThirdParty Revert "Merge branch 'ringrtc/v2.13.0'" 2021-09-23 17:20:30 -03:00
.clang-format format objc. 2016-07-14 23:15:06 -07:00
.gitattributes Supporting diffing of localizablestrings. 2015-09-14 12:26:47 +02:00
.gitignore Manage app store metadata with transifex 2021-04-22 12:53:43 -07:00
.gitmodules Convert to just using CocoaPods for dependencies 2020-01-02 12:03:57 -08:00
.ruby-version bump ruby version 2019-01-07 12:51:35 -07:00
.swiftlint.yml SwiftLint: attributes should be on preceding lines 2020-11-02 13:59:42 -08:00
.xcode-version Use Xcode 13 for nightly builds 2021-08-20 15:36:46 -07:00
BUILDING.md The Application Group string is located in TSConstants.swift. 2020-06-23 19:09:49 -07:00
CONTRIBUTING.md Update donation link in contribution instructions 2020-08-19 15:12:03 -05:00
Gemfile Update to Signal built OpenSSL 1.1.1k with M1 and Catalyst support 2021-06-17 14:45:29 -07:00
Gemfile.lock Update fastlane 2021-07-22 13:34:32 -07:00
Jenkinsfile ci labels PRs with GH title 2019-01-11 10:53:22 -07:00
LICENSE Update license. 2017-04-11 18:09:16 -04:00
MAINTAINING.md PR Feedback 2020-01-02 12:06:44 -08:00
Makefile Add nightly support to build script 2021-06-14 16:03:19 -07:00
Podfile Update Pods 2021-09-20 12:47:59 -07:00
Podfile.lock Update Cocoapods. 2021-09-23 17:22:05 -03:00
README.md Revert some of the bigger README changes for now, until we can do a deeper review 2019-06-11 17:14:04 -07:00
SignalServiceKit.podspec Convert to new Promise library 2021-09-03 11:41:34 -07:00

Signal iOS

Signal is a free, open source, messaging app for simple private communication with friends.

Available on the App Store

Also available on Android and Desktop.

Questions?

For troubleshooting and questions, please visit our support center or unofficial community forum.

Contributing Bug Reports

We use GitHub for bug tracking. Please search existing issues and create a new one if the issue is not yet tracked. For Android users, please use the Signal for Android issue tracker.

Contributing Translations

Help us translate Signal! The translation effort happens on Transifex.

Contributing Code

Instructions on how to setup your development environment and build Signal-iOS can be found in BUILDING.md. Other useful instructions for development can be found in the Development Guide wiki page. We also recommend reading the contribution guidelines.

Contributing Ideas

Have something you want to say about Signal Foundation projects or want to be part of the conversation? Get involved in the community forum.

Cryptography Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.

License

Licensed under GPLv3

Copyright 2014-2019 Open Whisper Systems

Apple and the Apple logo are trademarks of Apple Inc., registered in the U.S. and other countries. App Store is a service mark of Apple Inc., registered in the U.S. and other countries.