You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can reproduce this with the code you've pasted here, but oddly not with the basic tagwriter example in the examples dir. There, for instance, just updating the track number doesn't corrupt the file.
I don't think so -- the file is actually updated, so it's not just bailing out as would be the case there. I hope to have some time to look deeper into this in the next few days, but just thought I'd go ahead and post that comment in case anyone else was looking into this in parallel.
I as well can reproduce in v1.11.1 (e36a9ca). i.e. last release.
However appears to be fixed with later commits. (Like here: 9336c82)
Our local repo is a bit behind (github ssl issues) and the issue is not reproducible at this level.
v1 @ c8bcd15 - Tsuda Kageyu, 10 months ago : TableOfContentsFrame depends on ByteVectorList.
v2 @ bd4a45b - Tsuda Kageyu, 1 year, 1 month ago : Merge branch 'master' into merge-master-to-taglib2
FYI, the issue was introduced in commit 02eac18 and fixed in commit 9336c82.
I've also found that it impacts recent versions of VLC.
I vote for a new release too.
i've also found that commit 9336c82 has resolved the OGG issue. I patched taglib on my Gentoo system using the diff of the aforementioned commit.
Gentoo's ebuild for taglib also applies a CVE patch to the source code as well.. taking that [the CVE] into consideration, a new release would very much be in order, IMHO ..
This might also affect my loudgain normalizer. I wonder if a corrected version could be made that the distros pick up real quick?!
People might compile loudgain against the buggy version and start replaygaining huge collections. At least that was my plan until I read this … about 150,000 titles (not all Ogg Vorbis, though).
I can reproduce the problem using @jangler’s test files and the current version 0.2.7 of loudgain (commit 737a3b2).
Before: Good and playable using Audacious, VLC, spek, Audacity, others.
After:
loudgain: Could not open input: End of file.
Audacity: Could not detect type of file.
VLC: Shows tags, seems to play, but silence over the whole duration.
vorbisgain: File does not contain Vorbis data
spek: File contains no audio tracks
This is the code that writes to the file (tag.cc lines 232+):
voidtag_write_vorbis(scan_result *scan, bool do_album, char mode, char *unit) {
char value[2048];
TagLib::Ogg::Vorbis::File f(scan -> file);
TagLib::Ogg::XiphComment *tag = f.tag();
snprintf(value, sizeof(value), "%.2f %s", scan -> track_gain, unit);
tag -> addField("REPLAYGAIN_TRACK_GAIN", value);
snprintf(value, sizeof(value), "%.6f", scan -> track_peak);
tag -> addField("REPLAYGAIN_TRACK_PEAK", value);
// Only write album tags if in album mode (would be zero otherwise)if (do_album) {
snprintf(value, sizeof(value), "%.2f %s", scan -> album_gain, unit);
tag -> addField("REPLAYGAIN_ALBUM_GAIN", value);
snprintf(value, sizeof(value), "%.6f", scan -> album_peak);
tag -> addField("REPLAYGAIN_ALBUM_PEAK", value);
}
// extra tags mode -s e or -s lif (mode == 'e' || mode == 'l') {
snprintf(value, sizeof(value), "%.2f LUFS", scan -> loudness_reference);
tag -> addField("REPLAYGAIN_REFERENCE_LOUDNESS", value);
snprintf(value, sizeof(value), "%.2f %s", scan -> track_loudness_range, unit);
tag -> addField("REPLAYGAIN_TRACK_RANGE", value);
if (do_album) {
snprintf(value, sizeof(value), "%.2f %s", scan -> album_loudness_range, unit);
tag -> addField("REPLAYGAIN_ALBUM_RANGE", value);
}
}
f.save();
}
and this is the code to remove tags only (tag.cc lines 270+):
voidtag_clear_vorbis(scan_result *scan) {
TagLib::Ogg::Vorbis::File f(scan -> file);
TagLib::Ogg::XiphComment *tag = f.tag();
tag -> removeField("REPLAYGAIN_TRACK_GAIN");
tag -> removeField("REPLAYGAIN_TRACK_PEAK");
tag -> removeField("REPLAYGAIN_TRACK_RANGE");
tag -> removeField("REPLAYGAIN_ALBUM_GAIN");
tag -> removeField("REPLAYGAIN_ALBUM_PEAK");
tag -> removeField("REPLAYGAIN_ALBUM_RANGE");
tag -> removeField("REPLAYGAIN_REFERENCE_LOUDNESS");
f.save();
}
Interestingly, I have other Ogg Vorbis albums where I can do this many times, and nothing gets corrupted!
When I do a vorbiscomment on @jangler’s and my files, I find that @jangler’s files have empty comments CDDB=, ACOUSTID_FINGERPRINT= and ACOUSTID_ID= that are gone after trying to loudgain -r -k -se *.ogg them (which is expected behaviour). The files I used for testing all had NO empty tag fields (and weren’t corrupted).
Could it have something to do with that?
System: Linux Mint 19.1 x86_64
$ dpkg -l | grep libtag
ii libtag1-dev:amd64 1.11.1+dfsg.1-0.2build2 amd64 audio meta-data library - development files
ii libtag1v5:amd64 1.11.1+dfsg.1-0.2build2 amd64 audio meta-data library
ii libtag1v5-vanilla:amd64 1.11.1+dfsg.1-0.2build2 amd64 audio meta-data library - vanilla flavour
@scotchi Is there anything I can do to assist in a new release? There is still a workaround for this taglib bug in Mixxx that caused me to lose a bunch of metadata since it fails silently. The Mixxx devs don't want to bundle taglib, so it seems the only way this will get fixed in Mixxx is if there's a new taglib release.
I have been bitten by this bug, it corrupted half of my music collection when using python-rgain and then later vorbisgain. I thought the issue was with python-rgain, and was surprised when it happened again with vorbisgain.
I will try to test the beta, it's surprising that it hasn't been released for over 8 months.
The honest truth is that for the moment, for all practical purposes, TagLib doesn't have a maintainer.
I handed over the reigns for TagLib 12 years ago. I jumped back in for a couple weeks of activity hoping to push out a new release since the two maintainers since me had since disappeared, but a few days after that beta, I found out I was moving, and then by the time the dust settled on the move, the current pandemic had set in. Right now, with two small kids at home all the time, where I struggle to find the time to do my actual job, the chances of me finding a few days to work on a TagLib release before schools / day-cares reopen is basically zero. That hopefully will change in the coming months, but unless another maintainer (ideally someone with a history with the project) emerges, it'll be a while yet.
Today I have used the current loudgain.static version with the bug fix to process 36879 ogg vorbis files. Loudgain did not report a problem, but after the whole process I used oggz-validate to test all files and to my big surprise I got errors on 27008 of these files! The error message is always almost the same:
./path/music.ogg: Error:
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
serialno 1335062492: granulepos 0 on page with no completed packets, must be -1
The number of these messages per file is different (~8) and of course the reported serialno per file is different, too. Before starting loudgain.static I also executed this check and all files were ok. I don't know were the problem is, but because of this issue here I simply assume that it is a problem with taglib. If you need further information to reproduce this issue please don't hesitate to ask.
Unfortunately, I do not have a lot of Ogg files, but with the few I have, I used loudgain.static -s e *.ogg and then oggz-validate *.ogg, but no errors were reported. So it would be helpful if you could provide one or more example files with instructions how to reproduce the problem.
Now I found two candidates. Interesting is that both contain an embedded cover and that I do not get the granulepos 0 on page with no completed packets, must be -1 error when I remove the pictures before applying loudgain.
@ufleisch This is a very good hint! Although all my ogg files contain a cover, I've made some experiments with it. I have removed the cover of an example file which shows the described error after processing with loudgain.static, and after removing and reprocessing it with loudgain.static now everything was ok. I have added different covers and with some of it the error occurs and with others not, I cannot say what is the key difference between it. But also interesting: After editing any tag field in an already damaged file (with EasyTAG) and saving the file, oggz-validate does no longer report an error. I'm rellay confused about it.
You can reproduce this without the need of an external program. Just use a copy of empty.ogg from the TagLib sources (taglib/tests/data/) and add a large comment, which will fill more than a page. From Bash you can add a comment with 70000 'A' characters using
$ oggz-validate empty.ogg
empty.ogg: Error:
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
serialno 1002429366: granulepos 0 on page with no completed packets, must be -1
The problem is that such a large comment (as is the case when a cover art picture is embedded) will make the packet with the Vorbis comments span more than one Ogg page.
A.2. Encapsulation
Ogg encapsulation of a Vorbis packet stream is straightforward.
The first Vorbis packet (the identification header), which uniquely identifies
a stream as Vorbis audio, is placed alone in the first page of the logical Ogg
stream. This results in a first Ogg page of exactly 58 bytes at the very
beginning of the logical stream.
This first page is marked ’beginning of stream’ in the page flags.
The second and third vorbis packets (comment and setup headers) may span one
or more pages beginning on the second page of the logical stream. However many
pages they span, the third header packet finishes the page on which it
ends. The next (first audio) packet must begin on a fresh page.
The granule position of these first pages containing only headers is zero.
Here the granule position of the page containing the Vorbis comment is said to be zero. Probably when this was written, the author did not expect that Vorbis comments, which "is meant for short, text comments, not arbitrary metadata" (https://xiph.org/vorbis/doc/v-comment.html), would be (mis)used for cover art, and therefore its packet would never exceed the maximum possible physical page size of 65307 bytes. Therefore I suggest that TagLib should use a value of -1 for the granule position is such a case. This is also what is done by the official libogg/libvorbis.
I have added a pull request which should fix this issue.
@McOrvas You could create a loudgain with the patched TagLib and check if the validation succeeds now. Alternatively, you could just build the patched TagLib and then "heal" your files by just passing them to examples/tagwriter. @scotchi Since you probably know Ogg/Vorbis much better than I do, you could have a look at the pull request.
@ufleisch Thanks a lot for your detailed research! I have built your patched taglib version and used tagwriter with some of my corrupted files and afterwards all were error-free again (according to oggz-validate). Now I hope that your pull request will be integrated quickly and that a new release of taglib with all patches of this thread will be released.
Activity
scotchi commentedon Mar 27, 2018
I can reproduce this with the code you've pasted here, but oddly not with the basic
tagwriterexample in theexamplesdir. There, for instance, just updating the track number doesn't corrupt the file.jacobvosmaer commentedon Mar 27, 2018
scotchi commentedon Mar 27, 2018
FestusHagen commentedon Mar 29, 2018
I as well can reproduce in v1.11.1 (e36a9ca). i.e. last release.
However appears to be fixed with later commits. (Like here: 9336c82)
Our local repo is a bit behind (github ssl issues) and the issue is not reproducible at this level.
v1 @ c8bcd15 - Tsuda Kageyu, 10 months ago : TableOfContentsFrame depends on ByteVectorList.
v2 @ bd4a45b - Tsuda Kageyu, 1 year, 1 month ago : Merge branch 'master' into merge-master-to-taglib2
Maybe it's time for a release ...
Sigill commentedon Apr 1, 2018
FYI, the issue was introduced in commit 02eac18 and fixed in commit 9336c82.
I've also found that it impacts recent versions of VLC.
I vote for a new release too.
nguillaumin commentedon May 19, 2018
A new release would be great. How can we make it happen?
shymega commentedon Aug 23, 2018
i've also found that commit 9336c82 has resolved the OGG issue. I patched taglib on my Gentoo system using the diff of the aforementioned commit.
Gentoo's ebuild for taglib also applies a CVE patch to the source code as well.. taking that [the CVE] into consideration, a new release would very much be in order, IMHO ..
uklotzde commentedon Jun 18, 2019
I suppose Mixxx might also be affected by this severe bug in TagLib:
https://bugs.launchpad.net/mixxx/+bug/1833190
Pegasus-RPG commentedon Jun 18, 2019
Does this only affect OGG/Vorbis or any format in an OGG container?
Fix possible ogg packet losses (taglib/taglib#864)
Moonbase59 commentedon Jul 10, 2019
This might also affect my loudgain normalizer. I wonder if a corrected version could be made that the distros pick up real quick?!
People might compile loudgain against the buggy version and start replaygaining huge collections. At least that was my plan until I read this … about 150,000 titles (not all Ogg Vorbis, though).
Warning to save Ogg, see taglib/taglib#864
uklotzde commentedon Jul 11, 2019
This bug is a bomb and I wonder why no hotfix version has been released yet.
Moonbase59 commentedon Jul 12, 2019
I can reproduce the problem using @jangler’s test files and the current version 0.2.7 of loudgain (commit 737a3b2).
Before: Good and playable using Audacious, VLC, spek, Audacity, others.
After:
loudgain: Could not open input: End of file.
Audacity: Could not detect type of file.
VLC: Shows tags, seems to play, but silence over the whole duration.
vorbisgain: File does not contain Vorbis data
spek: File contains no audio tracks
This is the code that writes to the file (tag.cc lines 232+):
and this is the code to remove tags only (tag.cc lines 270+):
Interestingly, I have other Ogg Vorbis albums where I can do this many times, and nothing gets corrupted!
When I do a
vorbiscommenton @jangler’s and my files, I find that @jangler’s files have empty commentsCDDB=,ACOUSTID_FINGERPRINT=andACOUSTID_ID=that are gone after trying toloudgain -r -k -se *.oggthem (which is expected behaviour). The files I used for testing all had NO empty tag fields (and weren’t corrupted).Could it have something to do with that?
System: Linux Mint 19.1 x86_64
Moonbase59 commentedon Jul 12, 2019
Made another experiment:
vorbistageditto remove all empty tags in01-Les jours sans moi.ogg.loudgain -r -k -se 01\ -\ Les\ Jours\ sans\ moi-good.oggon it (which previously corrupted the file).So it must have something to do with empty tag fields. (I think.)
4 remaining items
matthewslaney commentedon May 4, 2020
@scotchi Is there anything I can do to assist in a new release? There is still a workaround for this taglib bug in Mixxx that caused me to lose a bunch of metadata since it fails silently. The Mixxx devs don't want to bundle taglib, so it seems the only way this will get fixed in Mixxx is if there's a new taglib release.
haplo commentedon May 20, 2020
I have been bitten by this bug, it corrupted half of my music collection when using python-rgain and then later vorbisgain. I thought the issue was with python-rgain, and was surprised when it happened again with vorbisgain.
I will try to test the beta, it's surprising that it hasn't been released for over 8 months.
scotchi commentedon May 21, 2020
The honest truth is that for the moment, for all practical purposes, TagLib doesn't have a maintainer.
I handed over the reigns for TagLib 12 years ago. I jumped back in for a couple weeks of activity hoping to push out a new release since the two maintainers since me had since disappeared, but a few days after that beta, I found out I was moving, and then by the time the dust settled on the move, the current pandemic had set in. Right now, with two small kids at home all the time, where I struggle to find the time to do my actual job, the chances of me finding a few days to work on a TagLib release before schools / day-cares reopen is basically zero. That hopefully will change in the coming months, but unless another maintainer (ideally someone with a history with the project) emerges, it'll be a while yet.
gnu: taglib: Update to 1.12-beta-1 [security fixes].
McOrvas commentedon Feb 6, 2021
Today I have used the current loudgain.static version with the bug fix to process 36879 ogg vorbis files. Loudgain did not report a problem, but after the whole process I used oggz-validate to test all files and to my big surprise I got errors on 27008 of these files! The error message is always almost the same:
The number of these messages per file is different (~8) and of course the reported serialno per file is different, too. Before starting loudgain.static I also executed this check and all files were ok. I don't know were the problem is, but because of this issue here I simply assume that it is a problem with taglib. If you need further information to reproduce this issue please don't hesitate to ask.
ufleisch commentedon Feb 7, 2021
Unfortunately, I do not have a lot of Ogg files, but with the few I have, I used
loudgain.static -s e *.oggand thenoggz-validate *.ogg, but no errors were reported. So it would be helpful if you could provide one or more example files with instructions how to reproduce the problem.ufleisch commentedon Feb 7, 2021
Now I found two candidates. Interesting is that both contain an embedded cover and that I do not get the
granulepos 0 on page with no completed packets, must be -1error when I remove the pictures before applying loudgain.McOrvas commentedon Feb 7, 2021
@ufleisch This is a very good hint! Although all my ogg files contain a cover, I've made some experiments with it. I have removed the cover of an example file which shows the described error after processing with loudgain.static, and after removing and reprocessing it with loudgain.static now everything was ok. I have added different covers and with some of it the error occurs and with others not, I cannot say what is the key difference between it. But also interesting: After editing any tag field in an already damaged file (with EasyTAG) and saving the file, oggz-validate does no longer report an error. I'm rellay confused about it.
Ogg: Set granule position to -1 if no packets finish on page (taglib#864
ufleisch commentedon Feb 8, 2021
You can reproduce this without the need of an external program. Just use a copy of empty.ogg from the TagLib sources (taglib/tests/data/) and add a large comment, which will fill more than a page. From Bash you can add a comment with 70000 'A' characters using
Then you get the error
The problem is that such a large comment (as is the case when a cover art picture is embedded) will make the packet with the Vorbis comments span more than one Ogg page.
See https://xiph.org/ogg/doc/framing.html
This is a bit contradictory to https://xiph.org/vorbis/doc/Vorbis_I_spec.html
Here the granule position of the page containing the Vorbis comment is said to be zero. Probably when this was written, the author did not expect that Vorbis comments, which "is meant for short, text comments, not arbitrary metadata" (https://xiph.org/vorbis/doc/v-comment.html), would be (mis)used for cover art, and therefore its packet would never exceed the maximum possible physical page size of 65307 bytes. Therefore I suggest that TagLib should use a value of -1 for the granule position is such a case. This is also what is done by the official libogg/libvorbis.
I have added a pull request which should fix this issue.
@McOrvas You could create a loudgain with the patched TagLib and check if the validation succeeds now. Alternatively, you could just build the patched TagLib and then "heal" your files by just passing them to
examples/tagwriter.@scotchi Since you probably know Ogg/Vorbis much better than I do, you could have a look at the pull request.
McOrvas commentedon Feb 9, 2021
@ufleisch Thanks a lot for your detailed research! I have built your patched
taglibversion and usedtagwriterwith some of my corrupted files and afterwards all were error-free again (according tooggz-validate). Now I hope that your pull request will be integrated quickly and that a new release of taglib with all patches of this thread will be released.Ogg: Set granule position to -1 if no packets finish on page (#864)
scotchi commentedon Feb 16, 2021
The new TagLib with this fix in is out now, so closing this issue.
update TagLib to 1.12