[BREAKGLASS] A private messenger for iOS. https://signal.org
Go to file
george-signal 98acf9687a
Fix a crash in stories tableview. (#4692)
Commit 04737ff044
attempted to fix an assertion in
StoriesViewController due to UITableView
complaining about inconsistent state. The issue
continues to happen. This diff fixes it once and
for all (I hope!).

The scenario that caused a crash prior to
04737ff044 was:

  Initially:
  models = [a,b,c]

  Database changes to [a,b]

  reloadStories (loading queue)
      newModels = [a,b]
      schedule block to run on main queue

  Database changes to [x, b]

  updateStories (loading queue)
      captures self.models, value is [a,b,c] // cue ominous music
      load from database
      newModels = [x,b]
      schedule block to run on main queue; will delete c and change a to x

  reloadStories.block runs on main queue
      self.models=newModels, value is [a,b]
      tableView.reloadData()  // UITableView thinks c is deleted

  updateStories.block runs on main queue
      self.models=newModels, value is [x,b]
      tableView.beginUpdates()
      tableView.delete(index: 2)  // crashes because c was already deleted

Post-04737ff the following scenario causes a
crash:

  Initially:
  models = [a,b,c]

  Database changes to [a,b]

  updateStories (loading queue)
      load from database
      models.set([a,b])
      schedule block to run on main queue which will delete c

  iOS gets a wild hair and decides to call some
  UITableViewDataSource methods.

  tableView(_, numberOfRowsInSection:)
      return [a,b].count  // Now UIKit thinks c is gone

  updateStories.block runs on main queue
      tableView.beginUpdates()
      tableView.delete(index: 2)  // crashes because 2 is out of bounds vs number of rows

This commit fixes the problem by ensuring the
read-modify-write that happens in updateStories
never reads older data than what UITableView
has been told about and also that updates to the
model are properly synchronized with
beginUpdates()...endUpdates().

Here's how to think about it: the database goes
through a series of changes. Call them v1, v2,
..., vN.

The loading queue will see each in turn. For each,
it will enqueue a corresponding block on the main
queue to update `model` and tell UITableView about
it.

From the POV of the main queue, each update occurs
in the scope of a UITableView update.

From the POV of the loading queue, each update
reads from exactly the preceding version (from
`trueModels`) and writes to exactly the next
version of `trueModels`.

Therefore, there are no data races.
2022-08-08 10:34:39 -07:00
.github Revert "CI: make bigger check depend on lighter check" 2022-07-27 15:04:23 -05:00
fastlane Update release notes 2022-08-03 15:52:53 -07:00
Instruments added missing Signalyzer file (#4017) 2022-02-21 08:07:21 +01:00
Pods@3151dddb44 Update to LibSignalClient 0.19.3 2022-08-05 15:01:21 -07:00
Scripts Allow 4k video playback 2022-08-07 09:19:45 -07:00
Signal Fix a crash in stories tableview. (#4692) 2022-08-08 10:34:39 -07:00
Signal.xcodeproj Add basic test for outgoing reaction message 2022-08-07 08:57:54 -05:00
Signal.xcworkspace Fix copyright year in Xcode template 2022-04-25 12:16:49 -07:00
SignalMessaging Prevent empty group updates from clobbering that a member joined via invite link 2022-08-03 15:04:31 -05:00
SignalNSE "Bump build to 5.50.0.6." (nightly-08-08-2022) 2022-08-08 11:36:03 -05:00
SignalServiceKit Update server params for LibSignalClient upgrade 2022-08-08 11:23:29 -05:00
SignalShareExtension "Bump build to 5.50.0.6." (nightly-08-08-2022) 2022-08-08 11:36:03 -05:00
SignalUI Redo media quality picker sheet in media editor. 2022-08-05 11:03:35 -07:00
SignalUITests Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:04 -03:00
ThirdParty Upgrade libwebp to v1.2.3 2022-08-01 15:55:52 -05:00
.clang-format Prefer clang-format for sorting #import/#include 2022-08-05 08:01:03 -05:00
.gitattributes Supporting diffing of localizablestrings. 2015-09-14 12:26:47 +02:00
.gitignore Remove "intermediates" flag from SDS codegen scripts 2022-07-05 11:52:00 -05:00
.gitmodules Convert to just using CocoaPods for dependencies 2020-01-02 12:03:57 -08:00
.ruby-version Update to ruby 2.6.9 2022-01-10 10:50:09 -06:00
.swiftlint.yml Disable the multiple_closures_with_trailing_closure rule 2022-07-26 19:15:52 -05: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 Remove call for public translations 2022-07-20 10:54:32 -05:00
Gemfile Remove cocoapods-binary 2022-04-26 09:20:14 -07:00
Gemfile.lock Update to RingRTC v2.20.9 2022-06-20 11:12:45 -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 Show progress during make dependencies 2022-01-27 09:39:48 -08:00
Podfile SignalServiceKit: no longer a separate pod 2022-08-05 16:14:15 -05:00
Podfile.lock Update to LibSignalClient 0.19.3 2022-08-05 15:01:21 -07:00
README.md Remove call for public translations 2022-07-20 10:54:32 -05: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 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-2022 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.