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

Crashes when accessing the RLMArray<RLMEmbeddedObject> element #7490

Open
YJianMu opened this issue Oct 19, 2021 · 3 comments · May be fixed by #7498
Open

Crashes when accessing the RLMArray<RLMEmbeddedObject> element #7490

YJianMu opened this issue Oct 19, 2021 · 3 comments · May be fixed by #7498

Comments

@YJianMu
Copy link

YJianMu commented Oct 19, 2021

How frequently does the bug occur?

All the time

Description

// RLMSupport.swift

public struct RLMCollectionIterator: IteratorProtocol {
private var iteratorBase: NSFastEnumerationIterator

internal init(_ collection: RLMCollection) {
    iteratorBase = NSFastEnumerationIterator(collection)
}

public mutating func next() -> RLMObject? {

// RLMEmbeddedObject forcibly convertsRLMObject crash
return iteratorBase.next() as! RLMObject?
}
}

Stacktrace & log output

Could not cast value of type 'XXXX.XXXXXXX' (0x103296750) to 'RLMObject' (0x7fff8696ab08).

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

10.17.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

ios

Build environment

Xcode version: ...
Dependency manager and version: ...

@leemaguire
Copy link
Contributor

Hi @YJianMu could you show us what your Realm Object classes look like so we can help you further?

@YJianMu
Copy link
Author

YJianMu commented Oct 25, 2021

Hi @YJianMu could you show us what your Realm Object classes look like so we can help you further?

@objc
class XXRecordRLMObj: RLMObject {

@objc dynamic var id: String = ""

@objc dynamic var type: XXRecordType = ""

@objc dynamic var localId: String = ""

@objc dynamic var startedAt: Int = 0

@objc dynamic var endedAt: Int = 0

@objc dynamic var recordedAt: Int = 0

@objc dynamic var status: XXRecordStatus = ""

@objc dynamic var sysMetadata: XXRecordSysMetadataRLMObj?

@objc dynamic var recMetadata: XXRecordRecMetadataRLMObj?

override class func primaryKey() -> String? {
return "localId"
}
}

@objc
class XXRecordSysMetadataRLMObj: RLMEmbeddedObject {

@objc dynamic var brand: String = "iPhone"

@objc dynamic var endReason: XXRecordEndReasonName = ""

@objc dynamic var model: String = XXDevice.deviceModel()

@objc dynamic var osVersion: String = XXDevice.systemVersion()

@objc dynamic var sysEventList: RLMArray = RLMArray(objectClassName: XXRecordSysEventRLMObj.className())

@objc dynamic var sysStatusList: RLMArray = RLMArray(objectClassName: XXRecordSysStatusRLMObj.className())
}

@objc
class XXRecordSysEventRLMObj: RLMEmbeddedObject {

@objc dynamic var eventName: XXRecordSysEventName = XXRecordSysEventNameForeground

@objc dynamic var eventParam: String?

@objc dynamic var recordAt: Int64 = 0
}

@objc
class XXRecordSysStatusRLMObj: RLMEmbeddedObject {

@objc dynamic var batteryCapacity: Double = 0

@objc dynamic var isCharging: Bool = false

@objc dynamic var isLowMem: Bool = false

@objc dynamic var recordAt: Int64 = 0
}

//Crashes when accessing the XXRecordRLMObj.sysMetadata.sysEventList element

@Bogdan-Belogurov
Copy link

@jsflax Is there any news? I'm having the same thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants