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

Random Realm crashes #5435

Closed
sync-by-unito bot opened this issue Apr 26, 2022 · 6 comments · Fixed by #6323
Closed

Random Realm crashes #5435

sync-by-unito bot opened this issue Apr 26, 2022 · 6 comments · Fixed by #6323
Assignees

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Apr 26, 2022

How frequently does the bug occur?

Sometimes

Description

We just rarely receive crash reports in the Crashlytics

Stacktrace & log output

The app was in the background for 20 minutes and then received some time to run in the background or was moving to the active state and crashed. One log also had Reading failed: Premature end of input and Connection[1]: Connection closed due to error errors but another one didn't. Not sure if important but also realm.refresh() method was called on two different Sync Realms. Overall, looks like network connection, obviously, becomes broken after app spends too much time in the background and then the app may crash when becoming active:

Crashed: Thread
0  libsystem_kernel.dylib         0x7964 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7378 pthread_kill + 268
2  libsystem_c.dylib              0x1ff50 abort + 164
3  Divtracker                     0x293238 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char) + 203116
4  Divtracker                     0x2933a8 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 203484
5  Divtracker                     0x293520 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 203860
6  Divtracker                     0x3160d8 realm::util::network::Service::BasicStreamOps<realm::util::network::ssl::Stream>::BufferedReadOperBase::advance() + 739340
7  Divtracker                     0x3159e4 void realm::util::network::Service::BasicStreamOps<realm::util::network::ssl::Stream>::async_buffered_read<std::__1::function<void (std::__1::error_code, unsigned long)> >(realm::util::network::ssl::Stream&, char*, unsigned long, int, realm::util::network::ReadAheadBuffer&, std::__1::function<void (std::__1::error_code, unsigned long)>) + 737560
8  Divtracker                     0x310cb8 realm::util::websocket::(anonymous namespace)::EZSocketImpl::async_read(char*, unsigned long, std::__1::function<void (std::__1::error_code, unsigned long)>) + 717804
9  Divtracker                     0x32200c (anonymous namespace)::WebSocket::frame_reader_loop() + 788288
10 Divtracker                     0x3162dc void realm::util::network::Service::AsyncOper::do_recycle_and_execute<std::__1::function<void (std::__1::error_code, unsigned long)>, std::__1::error_code&, unsigned long&>(bool, std::__1::function<void (std::__1::error_code, unsigned long)>&, std::__1::error_code&, unsigned long&) + 739856
11 Divtracker                     0x315df0 realm::util::network::Service::BasicStreamOps<realm::util::network::ssl::Stream>::BufferedReadOper<std::__1::function<void (std::__1::error_code, unsigned long)> >::recycle_and_execute() + 738596
12 Divtracker                     0x318f8c realm::util::network::Service::Impl::run() + 751296
13 Divtracker                     0x2b3d94 realm::sync::Client::run() + 337096
14 Divtracker                     0x41a8bc void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::'lambda0'()> >(void*) + 548316
15 libsystem_pthread.dylib        0x19a4 _pthread_start + 148
16 libsystem_pthread.dylib        0xea0 thread_start + 8

The app tried to open Realm synchronously and crashed, not sure if important but there was also remote function call in parallel:

Crashed: RealmManager.realm
0  libsystem_kernel.dylib         0x7b78 __pthread_kill + 8
1  libsystem_pthread.dylib        0x73bc pthread_kill + 268
2  libsystem_c.dylib              0x2051c abort + 168
3  Divtracker                     0x293238 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char) + 203116
4  Divtracker                     0x2933a8 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 203484
5  Divtracker                     0x293520 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 203860
6  Divtracker                     0x149078 realm::Cluster::init(realm::MemRef) + 48532
7  Divtracker                     0x157794 realm::ClusterTree::create_root_from_parent(realm::ArrayParent*, unsigned long) + 107696
8  Divtracker                     0x157b5c realm::ClusterTree::init_from_parent() + 108664
9  Divtracker                     0x2567e8 realm::Table::init(unsigned long, realm::ArrayParent*, unsigned long, bool, bool) + 469164
10 Divtracker                     0x17c12c realm::Group::create_table_accessor(unsigned long) + 257608
11 Divtracker                     0x17be14 realm::Group::do_get_table(unsigned long) + 256816
12 Divtracker                     0x36a3f8 realm::ObjectSchema::ObjectSchema(realm::Group const&, realm::StringData, realm::TableKey) + 22420
13 Divtracker                     0x372fa0 realm::ObjectStore::schema_from_group(realm::Group const&) + 58172
14 Divtracker                     0x3bfae4 realm::Realm::read_schema_from_group_if_needed() + 176132
15 Divtracker                     0x3bf7f0 realm::Realm::Realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>, std::__1::shared_ptr<realm::_impl::RealmCoordinator>, realm::Realm::MakeSharedTag) + 175376
16 Divtracker                     0x3405c8 realm::Realm::make_shared_realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>, std::__1::shared_ptr<realm::_impl::RealmCoordinator>) + 912636
17 Divtracker                     0x33faec realm::_impl::RealmCoordinator::do_get_realm(realm::Realm::Config, std::__1::shared_ptr<realm::Realm>&, realm::util::Optional<realm::VersionID>, realm::util::CheckedUniqueLock&) + 909856
18 Divtracker                     0x33f7a4 realm::_impl::RealmCoordinator::get_realm(realm::Realm::Config, realm::util::Optional<realm::VersionID>) + 909016
19 Divtracker                     0x3c05c4 realm::Realm::get_shared_realm(realm::Realm::Config) + 178916
20 Divtracker                     0xa2a4bc +[RLMRealm realmWithConfiguration:queue:error:] + 869 (shared_ptr.h:869)
21 Divtracker                     0xab76ec Realm.init(configuration:queue:) + 1580652 (<compiler-generated>:1580652)
22 Divtracker                     0xce75c closure #1 in static RealmManager.syncOpenRealm(configuration:) + 2019 (RealmManager.swift:2019)
23 Divtracker                     0xe33b0 partial apply for closure #1 in static RealmManager.syncOpenRealm(configuration:) + 4309595056 (<compiler-generated>:4309595056)
24 Divtracker                     0xb972dc MapSink.on(_:) + 43 (Map.swift:43)
25 Divtracker                     0xb974a0 protocol witness for ObserverType.on(_:) in conformance MapSink<A, B> + 2497568 (<compiler-generated>:2497568)
26 Divtracker                     0xba48f8 ObserveOnSink.run(_:_:) + 133 (ObserveOn.swift:133)
27 Divtracker                     0xba5b10 partial apply for thunk for @escaping @callee_guaranteed (@unowned @callee_guaranteed () -> ()) -> () + 2556560 (<compiler-generated>:2556560)
28 Divtracker                     0xbb312c partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed A, @unowned @callee_guaranteed @substituted <A> (@in_guaranteed A) -> () for <A>) -> () + 2611372 (<compiler-generated>:2611372)
29 Divtracker                     0xbb2870 closure #1 in RecursiveImmediateScheduler.schedule(_:) + 2609136 (<compiler-generated>:2609136)
30 Divtracker                     0xc12718 partial apply for closure #1 in DispatchQueueConfiguration.schedule<A>(_:action:) + 90 (DispatchQueueScheduler.swift:90)
31 Divtracker                     0xa01a8 thunk for @escaping @callee_guaranteed () -> () + 4309320104 (<compiler-generated>:4309320104)
32 libdispatch.dylib              0x1e68 _dispatch_call_block_and_release + 32
33 libdispatch.dylib              0x3a2c _dispatch_client_callout + 20
34 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
35 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
36 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
37 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
38 libsystem_pthread.dylib        0xe5c start_wqthread + 8

Can you reproduce the bug?

Not yet

Reproduction Steps

Unknown but for the first crash log it looks related to network connection timeout after leaving from the background

Version

10.25.0 and previous since I have continuous crash reports for 90 days

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iPadOS 15.4.0, iPadOS 15.3.1, iOS 15.4.1, ...

Build environment

ProductName:	macOS
ProductVersion:	12.3.1
BuildVersion:	21E258

/Applications/Xcode.app/Contents/Developer
Xcode 13.3.1
Build version 13E500a

/usr/local/bin/pod
1.11.3
Realm (10.25.0)
RealmSwift (10.25.0)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)

/usr/local/bin/carthage
0.38.0
(not in use here)

/usr/bin/git
git version 2.32.0 (Apple Git-132)
@ironage
Copy link
Contributor

ironage commented Apr 27, 2022

@anton-plebanovich thanks for reporting this! It looks like an assertion failure, is there an assertion message captured from stderr on these devices that you can share? Getting a reproduction case for this would be ideal, but I understand that may be difficult to obtain.

Guessing about the network thread sent to the background sounds promising. Maybe it is an edge case that we have not handled correctly; possibly ETIMEDOUT from ::recv().

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Apr 27, 2022

➤ James Stone commented:

[~daniel.tabacaru@mongodb.com] do you have capacity to investigate this?

This issue might just go away when we remove the custom websocket implementation as well.

@anton-plebanovich
Copy link

@ironage Sadly, there is only crash_info_entry_0: abort() called entry attached to the crash report. I doubt I can have easy to reproduce steps because we have a lot of users and they for sure background the app often but amount of crashes is few.

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Apr 28, 2022

➤ Daniel Tabacaru commented:

[~james.stone@mongodb.com] I don't have capacity at the moment. I could investigate it at a later point if it's not too urgent.

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Dec 21, 2022

➤ Ian Ward commented:

Hi. Going through old support tickets this quarter - has there been any more progress on this ticket?

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Dec 21, 2022

➤ michael-wb commented:

We had a customer ticket come in HELP-38176 that was closed since the customer never got back to us when requesting debug info to confirm that this is a related task. I had started looking into this - it seems to be a failure that occurs when SSL encryption is enabled, but it is difficult to reproduce.

I have been primarily focused on getting Platform Networking across the finish line and will get back to looking at this TR afterwards.

@michael-wb michael-wb mentioned this issue Feb 20, 2023
2 tasks
cbush pushed a commit to mongodb/docs-realm that referenced this issue Apr 27, 2023
<h3>Snyk has created this PR to upgrade realm from 11.5.2 to
11.6.0.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.
<hr/>

- The recommended version is **1 version** ahead of your current
version.
- The recommended version was released **22 days ago**, on 2023-03-23.


<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>realm</b></summary>
    <ul>
      <li>
<b>11.6.0</b> - <a
href="https://snyk.io/redirect/github/realm/realm-js/releases/tag/v11.6.0">2023-03-23</a></br><h3>Enhancements</h3>
<ul>
<li>Added configuration option <code>App.baseFilePath</code> which
controls where synced Realms and metadata is stored.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Fix type error when using <code>realm.create</code> in combination
with class base models. (since v11.0.0)</li>
</ul>
<h3>Compatibility</h3>
<ul>
<li>React Native &gt;= v0.71.0</li>
<li>Realm Studio v13.0.0.</li>
<li>File format: generates Realms with format v23 (reads and upgrades
file format v5 or later for non-synced Realm, upgrades file format v10
or later for synced Realms).</li>
</ul>
<h3>Internal</h3>



<ul>
<li>Test</li>
</ul>
      </li>
      <li>
<b>11.5.2</b> - <a
href="https://snyk.io/redirect/github/realm/realm-js/releases/tag/v11.5.2">2023-03-16</a></br><h3>Fixed</h3>
<ul>
<li>Suppress omitting <code>objcMsgsend</code> stubs to ensure backward
compatibility with Xcode 13. It can be observed as <code>Undefined
symbols for architecture arm64: "_objc_msgSend$allBundles", referenced
from: realm::copy_bundled_realm_files() in
librealm-js-ios.a(platform.o)</code> when using a React Native app for
iOS. (<a
href="https://snyk.io/redirect/github/realm/realm-js/issues/5511"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-js/issues/5511/hovercard">#5511</a>,
since v11.5.1)</li>
<li>It is not allowed to specify
<code>deleteRealmIfMigrationIsNeeded</code> and sync. This can lead to
error messages like <code>Schema validation failed due to the following
errors</code>. (<a
href="https://snyk.io/redirect/github/realm/realm-js/issues/5548"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-js/issues/5548/hovercard">#5548</a>,
v10.12.0)</li>
<li>Installation will no longer hang when using Node 19. (<a
href="https://snyk.io/redirect/github/realm/realm-js/issues/5136"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-js/issues/5136/hovercard">#5136</a>,
since v10.13.0)</li>
<li>Fixed enums which was accidentally exported on the
<code>Realm</code> namespace without a backing implementation. (<a
href="https://snyk.io/redirect/github/realm/realm-js/pull/5493"
data-hovercard-type="pull_request"
data-hovercard-url="/realm/realm-js/pull/5493/hovercard">#5493</a>,
since v11.0.0)</li>
<li>Converting local Realm to synced Realm crashes if an embedded object
is null. (<a
href="https://snyk.io/redirect/github/realm/realm-js/issues/5389"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-js/issues/5389/hovercard">#5389</a>,
since v10.13.0)</li>
<li>Fixed performance degradation on subqueries. (<a
href="https://snyk.io/redirect/github/realm/realm-core/issues/6327"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-core/issues/6327/hovercard">realm/realm-core#6327</a>,
since v6.0.0)</li>
<li>Fixed crash if secure transport returns an error with a non-zero
length. It can be observed as <code>Reading failed: Premature end of
input</code> in the log. (<a
href="https://snyk.io/redirect/github/realm/realm-core/issues/5435"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-core/issues/5435/hovercard">realm/realm-core#5435</a>,
since v10.0.0)</li>
<li>Creating subscriptions with queries having Unicode parameters causes
a server error e.g., <code>query from client:
"{"Product":"(stringQueryField BEGINSWITH B64\"2KzZhdi52Kpz\" )"}" could
not be parsed</code>. (<a
href="https://snyk.io/redirect/github/realm/realm-core/issues/6350"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-core/issues/6350/hovercard">realm/realm-core#6350</a>,
since v10.11.0)</li>
</ul>
<h3>Compatibility</h3>
<ul>
<li>React Native &gt;= v0.71.0</li>
<li>Atlas App Services.</li>
<li>Realm Studio v13.0.0.</li>
<li>File format: generates Realms with format v23 (reads and upgrades
file format v5 or later for non-synced Realm, upgrades file format v10
or later for synced Realms).</li>
</ul>
<h3>Internal</h3>
<ul>
<li>Upgraded Realm Core from v13.4.2 to v13.6.0. (<a
href="https://snyk.io/redirect/github/realm/realm-js/issues/5495"
data-hovercard-type="issue"
data-hovercard-url="/realm/realm-js/issues/5495/hovercard">#5495</a>)</li>
<li>All exceptions thrown out of Realm Core are now of type
<code>Exception</code>.</li>
</ul>
      </li>
    </ul>
from <a
href="https://snyk.io/redirect/github/realm/realm-js/releases">realm
GitHub release notes</a>
  </details>
</details>


<details>
  <summary><b>Commit messages</b></summary>
  </br>
  <details>
    <summary>Package name: <b>realm</b></summary>
    <ul>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/5196e76d65c5faffa4246daeb3683ac6d0d17b35">5196e76</a>
[11.6.0] Bump version</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/430afad55f3883c210449470788b93cc7dc41cd0">430afad</a>
Expose baseFilePath on App configuration (#5572)</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/22977eaf83d21acec6200f636f75e2c99d365085">22977ea</a>
Fix Create Call Signature (#5617)</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/832fd6a03d30123e047996005c6c1fc812653048">832fd6a</a>
Reenable all tests (#5606)</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/b7245b3c60305baee7a22c35857c71de4fb407ff">b7245b3</a>
Disable ccache for node builds (#5602)</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/bf629d375370285c8870b025c704b8a65b008c4f">bf629d3</a>
Prepare for vNext (#5567)</li>
<li><a
href="https://snyk.io/redirect/github/realm/realm-js/commit/46711a59419a87c8a3bf973d155ff8fe9a12818c">46711a5</a>
Prepare for 11.5.2 (#5560)</li>
    </ul>

<a
href="https://snyk.io/redirect/github/realm/realm-js/compare/d401cbeb41e76d42a45ba5dd4dc0b26eb71cbb9c...5196e76d65c5faffa4246daeb3683ac6d0d17b35">Compare</a>
  </details>
</details>
<hr/>

**Note:** *You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs.*

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJiYmYyNzYyNS0wZWU5LTQ2MDEtODU2MS00Y2Y4YmY2ZGY0MmYiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImJiZjI3NjI1LTBlZTktNDYwMS04NTYxLTRjZjhiZjZkZjQyZiJ9fQ=="
width="0" height="0"/>

🧐 [View latest project
report](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55/settings/integration?pkg&#x3D;realm&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

<!---
(snyk:metadata:{"prId":"bbf27625-0ee9-4601-8561-4cf8bf6df42f","prPublicId":"bbf27625-0ee9-4601-8561-4cf8bf6df42f","dependencies":[{"name":"realm","from":"11.5.2","to":"11.6.0"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"852e6e4f-be96-45c8-b370-1060f5ebee55","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":1,"publishedDate":"2023-03-23T17:43:34.744Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]})
--->

---------

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants