Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

flac -t claims MD5 signature unset in STREAMINFO, yet it is present? #192

Closed
smopucilowski opened this issue Jan 15, 2020 · 7 comments
Closed

Comments

@smopucilowski
Copy link

I've been hitting this issue and I can't seem to pin down the cause:

$ flac -t 07*.flac

flac 1.3.3
Copyright (C) 2000-2009  Josh Coalson, 2011-2016  Xiph.Org Foundation
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

07 - Natur - Flying.flac: WARNING, cannot check MD5 signature since it was unset in the STREAMINFO
ok
$ metaflac --list --block-type=STREAMINFO 07*.flac
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 2031 bytes
  maximum framesize: 12721 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 16639640
  MD5 signature: 009e8d8af89cf3d98f748aa9383f9e90

Running checks it seems to appear in about one in two hundred files. It is present in flac v1.3.{1,2}.

@smopucilowski
Copy link
Author

Possibly related to issue #155. Re-enconding the file over itself does not clear the issue.

@fspoettel
Copy link

Running into the same issue as well, similar number of files affected. Reencoding does not fix the issue. Can provide sample files if that helps with debugging.

@BezPowell
Copy link

Also experiencing this on Fedora 32 with flac 1.3.3.

@pastif
Copy link

pastif commented Jun 4, 2020

I'm having the same issue. It seems to only happen when files have two zeros at the start of the MD5 signature.

@smopucilowski
Copy link
Author

A --enable-debug build doesn't appear to trip the error.

@pastif
Copy link

pastif commented Jun 6, 2020

I built and installed flac 1.3.0 in a clean Arch Linux container and the same error happened. I installed flac 1.3.1 from the repos in an Ubuntu xenial container and couldn't reproduce the error. This is getting a bit beyond me, but I guess the bug is caused by something that changed in gcc or glibc. The memcmp call at line 1310 of src/flac/decode.c seems to be the trigger. I found this issue on the gcc bug tracker but don't understand it enough to know if it's actually the cause.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189

I tried building 1.3.3 on Arch with the optimization flag set to -O1 and that does appear to fix the issue (gcc 10.1.0-2 and glibc 2.31-5).

@pastif
Copy link

pastif commented Jun 7, 2020

I just noticed there's a patch for this on the Sourceforge bug tracker. It does fix the issue for me.

https://sourceforge.net/p/flac/bugs/478/

Is GitHub now the preferred place to report issues? The Xiph website still links to Sourceforge but I noticed someone there being told to reopen an issue here.

NotTsunami pushed a commit to NotTsunami/flac that referenced this issue Jul 30, 2020
https://sourceforge.net/p/flac/bugs/478/ states that has_md5sum fails
when the first byte of md5sum is zero. As reported in the linked issue
and on https://bugs.gentoo.org/719792, this occurs on gcc 9 and
above. Patch is authored by issue reporter from sourceforge.

Closes xiph#192.
NotTsunami pushed a commit to NotTsunami/flac that referenced this issue Jul 30, 2020
A bug in gcc versions 9.2 - 10.1 causes strings to get incorrectly
stripped when passed directly to memcmp (1). This is avoided by using
the FLAC__byte type, which is backwards compatible and avoids
compile-time checks. This was initially reported back March of this
year, and has only seen increasing bug reports due to the affected
gcc versions becoming more common as gcc 9 is included in Ubuntu
19.10 and later. The initial reporter also provided a patch in the
bug report (2), which is included in this PR with authorship
attributed to the original reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://sourceforge.net/p/flac/bugs/478/

Closes xiph#192.
NotTsunami pushed a commit to NotTsunami/flac that referenced this issue Aug 18, 2020
A bug in gcc versions 9.2 - 10.1 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which is
backwards compatible and avoids compile-time checks. This was
initially reported back March of this year, but has become more
prevalent with gcc 9.2 being shipped with the latest Ubuntu versions
(Ubuntu 19.10 and up ship with gcc 9.2). The initial reporter also
provided a patch in the bug report (2), which is included in this PR
with authorship attributed to the reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://sourceforge.net/p/flac/bugs/478/

Closes xiph#192.
NotTsunami pushed a commit to NotTsunami/flac that referenced this issue Sep 4, 2020
A bug in gcc versions 9.2 - 10.1 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which is
backwards compatible and avoids compile-time checks. This was
initially reported back March of this year, but has become more
prevalent with gcc 9.2 being shipped with the latest Ubuntu versions
(Ubuntu 19.10 and up ship with gcc 9.2). The initial reporter also
provided a patch in the bug report (2), which is included in this PR
with authorship attributed to the reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://sourceforge.net/p/flac/bugs/478/

Closes xiph#192.
NotTsunami added a commit to NotTsunami/flac that referenced this issue Sep 4, 2020
A bug beginning in gcc version 9.2 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which
is backwards compatible and avoids compile-time checks. This was
initially reported back in March 2020, but has seen more light since
Ubuntu 19.10 and up ship with gcc 9.2 as the default compiler. A
patch has been merged into the master gcc branch (2), but has not
been included in any versions as of this commit date.

The initial reporter provided a patch in their bug report (3), which
is included in this PR with authorship attributed to the reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6
(3) https://sourceforge.net/p/flac/bugs/478/

Closes xiph#192.
erikd pushed a commit that referenced this issue Mar 14, 2021
A bug beginning in gcc version 9.2 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which
is backwards compatible and avoids compile-time checks. This was
initially reported back in March 2020, but has seen more light since
Ubuntu 19.10 and up ship with gcc 9.2 as the default compiler. A
patch has been merged into the master gcc branch (2), but has not
been included in any versions as of this commit date.

The initial reporter provided a patch in their bug report (3), which
is included in this PR with authorship attributed to the reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6
(3) https://sourceforge.net/p/flac/bugs/478/

Closes #192.
@erikd erikd closed this as completed in 5f5035d Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants