tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

fdsan fails on closing SAF file descriptor at the end #634

Closed alexcohn closed 3 years ago

alexcohn commented 3 years ago

Description This is the ffprobe command executed:

[-print_format, json=c=1, -show_chapters, -loglevel, quiet, -show_entries, format=duration, -show_entries, format_tags=artist,title,album, -show_entries, stream_tags=artist,title,album, -select_streams, a, -i, saf:69/28 - Kapitel 8_ Mondmänner und Katzonauten.mp3]

And this is the sigabrt crash:

A/libc: fdsan: attempted to close file descriptor 69, expected to be unowned, actually owned by ParcelFileDescriptor 0xcd37e73
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14414 (DefaultDispatch), pid 14385 (audiobook.debug)
Tested targeting android 11 using a pixel 4.

Expected behavior fdsan should allow the SAF descriptor to be closed

Current behavior fdsan considers the SAF descriptor as owned by ParcelFileDescriptor

Environment

Other Confirmed on emulator.

tanersener commented 3 years ago

These two pages, File descriptor sanitizer (fdsan) and fdsan explain what has changed in Android 11 (API Level 30) and what must be done to fix this.

Unfortunately, they recommend to use fdsan to close the native fds. But the problem is, fdsan is only available on API Level 29 >=. So, using fdsan directly is not possible. Any suggestions?

tanersener commented 3 years ago

Apparently, ParcelFileDescriptor.close() method that we call inside Config.closeParcelFileDescriptor is already closing the fd. If we close the fd again fdsan complains that we're double-closing it. So, I'll remove the close from the native method to fix this.

E/fdsan: double-close of file descriptor 64 detected

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tanersener commented 3 years ago

This project will be retired. Please consider switching to FFmpegKit. This issue is fixed there.