Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Segfault while scanning #867

Closed
phlnx opened this issue Jun 22, 2021 · 4 comments
Closed

Segfault while scanning #867

phlnx opened this issue Jun 22, 2021 · 4 comments

Comments

@phlnx
Copy link

phlnx commented Jun 22, 2021

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
Copy link
Collaborator

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 JamesHeinrich/getID3#299.

@phlnx
Copy link
Author

phlnx commented Jun 22, 2021

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
Copy link
Collaborator

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
Copy link
Collaborator

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants