Skip to content

Commit

Permalink
Fix shaper segfault (#633)
Browse files Browse the repository at this point in the history
* `managedString` might be inlined and garbage collected before the beginning of JNI call

* add other missed `reachabilityBarrier`s
  • Loading branch information
SergeevPavel authored Dec 14, 2022
1 parent c62037f commit a15632c
Show file tree
Hide file tree
Showing 32 changed files with 521 additions and 274 deletions.
12 changes: 8 additions & 4 deletions skiko/src/commonMain/kotlin/org/jetbrains/skia/Bitmap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ class Bitmap internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerH
*/
fun swap(other: Bitmap) {
Stats.onNativeCall()
_nSwap(_ptr, getPtr(other))
_imageInfo = null
reachabilityBarrier(this)
reachabilityBarrier(other)
try {
_nSwap(_ptr, getPtr(other))
_imageInfo = null
} finally {
reachabilityBarrier(this)
reachabilityBarrier(other)
}
}

override val imageInfo: ImageInfo
Expand Down Expand Up @@ -685,6 +688,7 @@ class Bitmap internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerH
)
this
} finally {
reachabilityBarrier(this)
reachabilityBarrier(pixelRef)
}
}
Expand Down
Loading

0 comments on commit a15632c

Please sign in to comment.