I get `EXC_BAD_ACCESS` in an Objective-C++ object ...
# kotlin-native
d
I get
EXC_BAD_ACCESS
in an Objective-C++ object deallocation stack in thread
Queue: com.google.firebase.firestore (serial)
where it is, er, "releasing its reference" to a Swift closure I passed it. Inside the Swift closure is a reference* to a Kotlin lambda that was passed into my Swift code from my Kotlin code. when I refactor the code to not pass the Kotlin lambda into Swift, the crash (seems to**) go away. Am I missing something obvious? Should I
.freeze()
that lambda? *The Kotlin lambda does not need to be called for the crash to occur. **The crash is known to both occur and not occur without any code changes, but I seem to have found a configuration where it reliably happened 100% of the time, then refactoring out the lambda made it go away.. could theoretically still be a red herring.
s
in thread
Queue: com.google.firebase.firestore (serial)
where it is, er, “releasing its reference” to a Swift closure I passed it. Inside the Swift closure is a reference* to a Kotlin lambda
Known issue. You have incorrect object sharing.
Should I
.freeze()
that lambda?
This should help.
d
help?
what do you mean?
is the known issue documented somewhere?
s
what do you mean?
I mean that freezing lambda will likely fix the issue.
is the known issue documented somewhere?
https://kotlinlang.org/docs/reference/native/concurrency.html#object-transfer-and-freezing In Kotlin/Native you can’t share a mutable object with other thread.