Android-TiffBitmapFactory
Android-TiffBitmapFactory copied to clipboard
fdsan: attempted to close file descriptor 81, expected to be unowned, actually owned by ParcelFileDescriptor 0xebcfa4c
I am getting the following when trying to decode a TIFF file:
2022-08-11 17:47:41.526 9426-9426/com.therealbluepandabear.pixapencil A/libc: fdsan: attempted to close file descriptor 81, expected to be unowned, actually owned by ParcelFileDescriptor 0xebcfa4c
2022-08-11 17:47:41.526 9426-9426/com.therealbluepandabear.pixapencil A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 9426 (bear.pixapencil), pid 9426 (bear.pixapencil)
Code:
TiffBitmapFactory.decodeFileDescriptor(parcelFileDescriptor.fd, options)
Check is this FileDescriptor not opened in one more place.
@Beyka I don't think it is.
Here's the full code:
fun getBitmapFromUri(
uri: Uri,
onTaskFinished: (OutputCode, Bitmap?, String?) -> Unit) {
var outputCode = OutputCode.Success
var bitmap: Bitmap? = null
var exceptionMessage: String? = null
try {
val contentResolver = context.applicationContext.contentResolver
val parcelFileDescriptor: ParcelFileDescriptor = contentResolver.openFileDescriptor(uri, "r")!!
bitmap = TiffBitmapFactory.decodeFileDescriptor(parcelFileDescriptor.fd, null)
parcelFileDescriptor.close()
} catch (ioException: IOException) {
exceptionMessage = ioException.message
outputCode = OutputCode.Failure
} finally {
onTaskFinished(outputCode, bitmap, exceptionMessage)
}
}
Same thing happens to me. Occurs on android 11 and later. It seems that the reason is that it is closed in the destructor of NativeDecoder. NativeDecoder::~NativeDecoder() { LOGI("Destructor"); if (image) { TIFFClose(image); image = NULL; }
Is there any way to fix it?
This is clearly a remnant of decodePath, so if you specify the filedescriptor of parcelFileDescriptor, deleting it without permission is a bug, so I would like you to fix it. I don't know the impact on others, but if it's only decoding, it can be avoided by using the NDK that ndk-builds the one that commented out "TIFFClose(image)" from the destructor of NativeDecoder, but it's a little troublesome.
@therealbluepandabear @adachi-hideki Deleted closing of IMAGE in native if it was oppened from FD. Please try 0.9.9.1 build
@therealbluepandabear @adachi-hideki Deleted closing of IMAGE in native if it was oppened from FD. Please try 0.9.9.1 build
Thanks I'll try it :)
@therealbluepandabear is it works? If yes - I will close this issue
@therealbluepandabearそれは動作しますか?はいの場合 - この問題をクローズします
Yes. Thank you very much.
I quit android dev, but I trust that it's probably fixed, this can be closed.