owncloud / music

:notes: Music app for ownCloud
GNU Affero General Public License v3.0
569 stars 199 forks source link

Segfault while scanning #867

Closed phlnx closed 3 years ago

phlnx commented 3 years ago

I was wondering why the automatic scan would not go past ~900 songs out of ~10000, so I found the shell command, launched it with --debug, and at the 908th music file I got this:

An unhandled exception has been thrown:
TypeError: decbin(): Argument #1 ($num) must be of type int, string given in /var/www/nextcloud/apps/music/3rdparty/getID3/getid3/getid3.lib.php:437
Stack trace:
#0 /var/www/nextcloud/apps/music/3rdparty/getID3/getid3/getid3.lib.php(437): decbin()
#1 /var/www/nextcloud/apps/music/3rdparty/getID3/getid3/module.tag.id3v2.php(1959): getid3_lib::Dec2Bin()
#2 /var/www/nextcloud/apps/music/3rdparty/getID3/getid3/module.tag.id3v2.php(355): getid3_id3v2->ParseID3v2Frame()
#3 /var/www/nextcloud/apps/music/3rdparty/getID3/getid3/getid3.php(675): getid3_id3v2->Analyze()
#4 /var/www/nextcloud/apps/music/lib/Utility/ExtractorGetID3.php(74): getID3->analyze()
#5 /var/www/nextcloud/apps/music/lib/Utility/Scanner.php(175): OCA\Music\Utility\ExtractorGetID3->extract()
#6 /var/www/nextcloud/apps/music/lib/Utility/Scanner.php(127): OCA\Music\Utility\Scanner->extractMetadata()
#7 /var/www/nextcloud/apps/music/lib/Utility/Scanner.php(103): OCA\Music\Utility\Scanner->updateAudio()
#8 /var/www/nextcloud/apps/music/lib/Utility/Scanner.php(473): OCA\Music\Utility\Scanner->update()
#9 /var/www/nextcloud/apps/music/lib/Command/Scan.php(117): OCA\Music\Utility\Scanner->scanFiles()
#10 /var/www/nextcloud/apps/music/lib/Command/Scan.php(91): OCA\Music\Command\Scan->scanUser()
#11 /var/www/nextcloud/apps/music/lib/Command/BaseCommand.php(63): OCA\Music\Command\Scan->doExecute()
#12 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Music\Command\BaseCommand->execute()
#13 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#14 /var/www/nextcloud/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#15 /var/www/nextcloud/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#16 /var/www/nextcloud/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run()
#17 /var/www/nextcloud/console.php(100): OC\Console\Application->run()
#18 /var/www/nextcloud/occ(11): require_once('...')
#19 {main}Segmentation fault

I temporarily fixed it by changing line 437 from:

$binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;

to:

$binstring = (($i == count($bytes) - 1) ? decbin(intval($bytes[$i])) : str_pad(decbin(intval($bytes[$i])), 8, '0', STR_PAD_LEFT)).$binstring;

Upon re-launching the shell command, the scan has resumed. Unfortunately I am not sure I can pinpoint the exact mp3 file that caused the issue.

paulijar commented 3 years ago

Thanks for the report. This seems like a bug in the getID3 library we use for the metadata extraction. Obviously, the function Dec2Bin is designed to operate on integers but module.tag.id3v2.php(1959) passes it a string. This has probably worked before but newer PHP versions are more strict with the types. Are you using PHP8?

There actually already seems to be an open issue about this at https://github.com/JamesHeinrich/getID3/issues/299.

phlnx commented 3 years ago

Hello, thank you very much for your reply. I confirm that I am using php8.0. And after posting my report here, and re-read the path to the file, I imagined it had something to do with an external library. I was not aware of the open issue, thank you for the link. Feel free to close this issue if the getID3 issue covers this problem as well.

paulijar commented 3 years ago

No problem. Let's keep this report open until when I have merged the fixed library version and made a Music app release with it.

paulijar commented 3 years ago

Music v1.2.1 with an updated getID3 version is now out. It should fix the problem.