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

Index out of bounds. #7210

Closed
igrechuhin opened this issue Apr 14, 2021 · 2 comments
Closed

Index out of bounds. #7210

igrechuhin opened this issue Apr 14, 2021 · 2 comments
Assignees

Comments

@igrechuhin
Copy link

igrechuhin commented Apr 14, 2021

!!! MANDATORY TO FILL OUT !!!

Goals

No out of bounds.

Expected Results

No out of bounds.

Actual Results

Undefined behavior.

Steps for others to Reproduce

Code Sample

private var realm: Realm {
        let configuration = Realm.Configuration(
            fileURL: URL(
                fileURLWithPath: Resource.dataPath(basePath: Resource.dataFolder, forName: "default", ofType: "realm"),
                isDirectory: false
            ),
            deleteRealmIfMigrationNeeded: true,
            shouldCompactOnLaunch: { fileSize, dataSize in
                dataSize * 2 < fileSize
            }
        )
        do {
            return try Realm(configuration: configuration)
        } catch {
            fatalError(error.localizedDescription)
        }
    }

func objects<Element>(_ type: Element.Type, sortByDate: Bool = true) -> Results<Element> where Element: Object {
        if sortByDate {
            return realm.objects(type).sorted(byKeyPath: "date")
        }
        return realm.objects(type)
    }

Error 1

/SourcePackages/checkouts/realm-core/src/realm/db.cpp: runtime: Undefined Behavior: Index 231 out of bounds for type '(anonymous namespace)::Ringbuffer::ReadCount [32]'

Out of bounds index
#0 0x00000001026a79bc in (anonymous namespace)::Ringbuffer::get_next() ()
#1 0x00000001026a4577 in realm::DB::low_level_commit(unsigned long long, realm::Transaction&) at xxx/SourcePackages/checkouts/realm-core/src/realm/db.cpp:2287
#2 0x00000001026a303a in realm::DB::do_commit(realm::Transaction&) at xxx/SourcePackages/checkouts/realm-core/src/realm/db.cpp:2086
#3 0x000000010269e4c2 in realm::Transaction::commit() at xxx/SourcePackages/checkouts/realm-core/src/realm/db.cpp:2507
#4 0x00000001012c1668 in realm::_impl::RealmCoordinator::open_db() at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:520
#5 0x00000001012be179 in realm::_impl::RealmCoordinator::do_get_realm(realm::Realm::Config, std::__1::shared_ptrrealm::Realm&, realm::util::Optionalrealm::VersionID, realm::util::CheckedUniqueLock&) at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:316
#6 0x00000001012bdc88 in realm::impl::RealmCoordinator::get_realm(realm::Realm::Config, realm::util::Optionalrealm::VersionID) at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:288
#7 0x00000001018ebb7d in realm::Realm::get_shared_realm(realm::Realm::Config) at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/shared_realm.cpp:129
#8 0x0000000100d052a0 in +[RLMRealm realmWithConfiguration:queue:error:] at xxx/SourcePackages/checkouts/realm-cocoa/Realm/RLMRealm.mm:440
#9 0x0000000100f82141 in @nonobjc RLMRealm.__allocating_init(configuration:queue:) ()
#10 0x000000010102775d in Realm.init(configuration:queue:) at xxx/SourcePackages/checkouts/realm-cocoa/RealmSwift/Realm.swift:92
#11 0x00000001003453b2 in DB.realm.getter at xxx/DB.swift:21
#12 0x00000001003480e6 in DB.objects(
:sortByDate:) at xxx/DB.swift:91

Error 2

/SourcePackages/checkouts/realm-core/src/realm/db.cpp: runtime: Undefined Behavior: Index 57 out of bounds for type '(anonymous namespace)::Ringbuffer::ReadCount const[32]'

Out of bounds index
#0 0x000000010269af93 in (anonymous namespace)::Ringbuffer::get(unsigned int) const ()
#1 0x000000010269f884 in realm::DB::grab_read_lock(realm::DB::ReadLockInfo&, realm::VersionID) at xxx/SourcePackages/checkouts/realm-core/src/realm/db.cpp:1901
#2 0x00000001026964cd in realm::DB::start_read(realm::VersionID) at xxx/SourcePackages/checkouts/realm-core/src/realm/db.cpp:2359
#3 0x00000001012c9694 in realm::impl::RealmCoordinator::begin_read(realm::VersionID, bool) at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:538
#4 0x00000001018ea724 in realm::Realm::begin_read(realm::VersionID) at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/shared_realm.cpp:121
#5 0x00000001018ea24d in realm::Realm::read_group() at xxx/SourcePackages/checkouts/realm-core/src/realm/object-store/shared_realm.cpp:81
#6 0x0000000100cff823 in [RLMRealm group] at xxx/SourcePackages/checkouts/realmcocoa/Realm/RLMRealm.mm:180
#7 0x000000010064eaa8 in RLMClassInfo::table() const at xxx/SourcePackages/checkouts/realm-cocoa/Realm/RLMClassInfo.mm:42
#8 0x00000001008b10ee in RLMGetObjects at xxx/SourcePackages/checkouts/realm-cocoa/Realm/RLMObjectStore.mm:195
#9 0x000000010102ce3f in Realm.objects
(:) at xxx/SourcePackages/checkouts/realm-cocoa/RealmSwift/Realm.swift:646
#10 0x00000001003480fd in DB.objects(_:sortByDate:) at xxx/DB.swift:91

Version of Realm and Tooling

Realm framework version: 10.7.2 / 10.5.5

Realm Object Server version: ?

Xcode version: 12.4

iOS/OSX version: OSX 11.2.3

Dependency manager + version: SPM

@dianaafanador3
Copy link
Contributor

Hi @igrechuhin, thanks for taking the time to report this issue. Have you been able to solve this?

@dianaafanador3
Copy link
Contributor

dianaafanador3 commented Jul 27, 2021

Closing this because there is no answer from the user

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants