badoo / Reaktive

Kotlin multi-platform implementation of Reactive Extensions
Apache License 2.0
1.17k stars 58 forks source link

[2.0] Fixed AtomicReference primitive updates stuck on native #739

Closed arkivanov closed 1 year ago

arkivanov commented 1 year ago

There is a bug in Kotlin/Native that leads to unnecessary unboxing-boxing of large primitives with inline functions. As a result, getAndChange, changeAndGet and change function may stuck. This happens because AtomicReference compares by reference, and the references are different. The workaround is to specify variable types as Any? and use unsafe cast which prevents unboxing-boxing.