Bug 4803 - Scanner crashes on 'Rating' flac tag
: Scanner crashes on 'Rating' flac tag
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Scanner
: 6.5.2
: PC Windows XP
: P5 normal with 1 vote (vote)
: 7.7.0
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-04 19:41 UTC by Jim McAtee
Modified: 2011-12-03 13:51 UTC (History)
4 users (show)

See Also:
Category: ---


Attachments
slimserver log (3.27 KB, text/plain)
2007-03-04 19:42 UTC, Jim McAtee
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim McAtee 2007-03-04 19:41:11 UTC
Someone gave me a flac album that contained a vorbis comment/tag named 'RATING' with a value of 2.5.  No idea where this tag came from, but apparently the SlimServer scanner doesn't like either the tag or else the value it contains.  Log to follow.
Comment 1 Jim McAtee 2007-03-04 19:42:39 UTC
Created attachment 1829 [details]
slimserver log
Comment 2 Spies Steven 2007-03-05 16:23:05 UTC
Jim, I am not able to reproduce the behavior that you are seeing here. Are you using something other then a standard install perhaps? As far as the "RATING" tag goes, I know that dBpoweramp uses it. The odd thing is Slim Server assumes a 100 scale when dBpoweramp use a 5 scale, could be another bug.
Comment 3 Jim McAtee 2007-03-05 16:48:19 UTC
Did some more testing.  The column in the tracks table is an unsigned tiny int, so it can accept value from 0 to 255.  It looks like SlimServer is doing no data validation on what it reads from the RATINGS tag.  Values from 0 to 255 work, but decimal values, negative numbers, values greater than 255, or alpha characters all cause the failure.
Comment 4 Spies Steven 2007-03-15 09:29:44 UTC
Dan, can you take a look at this one? It sounds similar to Bug 4823 however I have seen decimal values for rating such as 2.5 for 2.5 out of 5. It looks like SlimServer is expecting a whole number out of 100. Ideas?
Comment 5 Chris Owens 2007-05-15 14:04:20 UTC
This is not going to make it in to 6.5.2.  If we don't want to change the data type for this value, we could at least validate the input and discard it if it's unsuited to the tiny int type.
Comment 6 KDF 2007-05-15 14:54:30 UTC
bug 4823 required a check for validating DISC and DISCC, so it should be as simple as adding RATING to this check like so:

Schema.pm line 1594:
        # Bug 4823, 4803 - check boundaries set by our tinyint schema.
  	         for my $tag (qw(DISC DISCC RATING)) {

and add a last line in that section for safety:

$tag = int $tag;

of course, it could also be processed on its own to do some smart scaling for something like 2.5 (ie assume scale of 5 and  assign 50/100)
  	 
Comment 7 Ross Levine 2007-05-25 14:48:43 UTC
This doesn't seem to be an issue with the current nightly build, Jim (or anyone) are you still seeing this? 
Comment 8 Jim McAtee 2007-05-25 14:57:22 UTC
Haven't tested it in quite a while.  Was the patch checked in?  I'll check it out tonight or tomorrow.
Comment 9 KDF 2007-05-25 18:22:48 UTC
no patches have been added (hence no change number) in regard to this issue.  Earlier testers reported being unable to reproduce, so Ross may also be unable to reproduce.  
Comment 10 Jim McAtee 2007-05-26 23:19:27 UTC
Here's what I'm finding, after more testing:

Running with the bundled MySQL server for Windows, 5.0.22-community-nt, the scanner doesn't crash.  Decimal numbers are rounded or truncated, alpha characters are ignored, out of range values are ignored.  But running with the latest non-bundled MySQL, 5.0.41-community-nt, it can still crash the scanner (though I find that decimal values are now rounded).  So, it's dependant on the behavior of MySQL, which may explain why it isn't always reproduced.  I can't find anything obvious in the MySQL config files of my installed instance and that of the bundled MySQL, so I suspect it may be in the way SlimServer's MySQL binary is compiled for Windows.

Perhaps the severity or the priority of the bug should be set very low, although I can't think of a good reason why you wouldn't want to validate all data before trying to store it in the database.  The only question seems to be whether you'd limit the range to 0-100, or 0-255.  I don't believe ratings are actually used for anything within SlimServer, but they're displayed on the track detail page as 'n/100'.
Comment 11 Ross Levine 2007-05-29 13:31:48 UTC
I'll lower the priority and severity now that this is more clear. Thank you for clarifying Jim. 
Comment 12 Blackketter Dean 2007-12-29 15:38:23 UTC
Happy to look at this after 7.0 and/or welcome patches.
Comment 13 Michael Herger 2008-09-16 23:21:08 UTC
*** Bug 9500 has been marked as a duplicate of this bug. ***
Comment 14 James Richardson 2009-06-01 10:08:42 UTC
Jim: Is this still a valid issue with SC 7.4
Comment 15 Jim McAtee 2009-06-01 13:05:29 UTC
(In reply to comment #14)
> Jim: Is this still a valid issue with SC 7.4

Which branch?  Since the behavior changed from one version of MySQL to another, it may be different between MySQL and SQLite.
Comment 16 James Richardson 2009-06-01 13:34:18 UTC
Well...since SQLite will be the next release, I'd say that one should be the testing target.
Comment 17 Jim McAtee 2009-06-01 14:31:20 UTC
With SQLite, no crash.  There isn't really a datatype of tinyint in SQLite - there's only one type of integer.  In fact, you can even store strings and real numbers in columns declared as tinyint.

So if you were never to do any data validation, you won't cause a crash with SQLite.  I would contend, however, that it's a big mistake to be so lax and that doing so will inevitably cause SqueezeCenter itself to choke on the data at some point.  Doing the validation of metadata at scan time makes a lot more sense.  Furthermore, if you really do want to pretend that the system is independent of the DBMS, then data validation would be a very good idea.

Until someone actually figures out _what_ is expected in the ratings column (is it 0 to 5, 0 to 10, 0 to 100 or something else?) then for the time-being you should at least make sure the value fits into the standard definition of an unsigned tinyint - 0 to 255.

From the SQLite FAQ:

(3) SQLite lets me insert a string into a database column of type integer!

This is a feature, not a bug. SQLite uses dynamic typing. It does not enforce data type constraints. Any data can be inserted into any column. You can put arbitrary length strings into integer columns, floating point numbers in boolean columns, or dates in character columns. (...)
Comment 18 Andy Grundman 2009-07-29 14:40:36 UTC
Moving all SQLite-related bugs to 8.0.
Comment 19 Andy Grundman 2011-01-12 12:08:29 UTC
SQLite bugs need to go back to 7.6 target.
Comment 20 SVN Bot 2011-09-19 06:22:52 UTC
 == Auto-comment from SVN commit #33476 to the slim repo by agrundman ==
 == http://svn.slimdevices.com/slim?view=revision&revision=33476 ==

Fixed bug 4803, warn and reject on RATING tags that aren't an integer 0-255
Comment 21 Mike Walsh 2011-11-14 21:19:01 UTC
POPM, which is id3, uses 0-255, thats in the id3 spec.

vorbis has no such spec, however, the scale winamp uses, and media monkey, and others is 0-100

in either case, regardless of the raw numbers, apps reduce / interpret the raw numbers to 0-5 stars.

dos this fix mean SBS ignores ratings in vorbis now?

go to the ed of the thread:

http://forums.slimdevices.com/showthread.php?t=59929
Comment 22 Jim McAtee 2011-12-03 13:51:00 UTC
(In reply to comment #20)
> Fixed bug 4803, warn and reject on RATING tags that aren't an integer 0-255

Andy, the warnings being logged for rejected RATING values seem to be causing some confusion, especially for people who experience scanner crashes. I'd suggest that these not be logged.

http://forums.slimdevices.com/showthread.php?t=92015

Probably a topic for a new bug, but I'd also suggest that ratings value be stored in the DB as floating or fixed point numbers, so that numbers like 2.5 or 3.5 would be be acceptable. If some day you needed to fit those to some scale or to display the ratings using stars, you might add a library pref for 'Ratings Scale'.