package vcompare int overflow
Closed / Fixed1563836fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-09-23 01:46:57
% package vcompare [expr 1<<31] [expr (1<<31)-1] -1
andreas_kupriesplain2006-09-26 04:29:46
Logged In: YES user_id=75003 Do we really wish to extend version numbers beyond 32 bit ? I.e. allow bignums ? Did we discuss this ?
nobodyplain2006-09-26 09:19:13
Logged In: NO Yes. As Lars pointed out, simply doing the comparison on strings scales fine.
andreas_kupriesplain2006-09-26 23:33:15
Logged In: YES user_id=75003 Thinking about it I can agree that string compare is good enough. The only problem a strcmp would have are leading zeros, and those are disallowed in version numbers and checked for early.
dgpplain2006-09-26 23:39:55
Logged In: YES user_id=80530 leading zeros are disallowed?
andreas_kupriesplain2006-09-26 23:52:40
Logged In: YES user_id=75003 I shouldn't make statements like this early in the morning. Checking the code I find nothing to support my assertion. No idea why I was thinking this. :( Shaking head. Ok, this however means that 1.0002.3 is a valid version number, and now a plain strcmp would consider it different from 1.2.3. Numerically however they are equivalent. If we want numerical checking our code has to skip leading "0"-digits before invoking the strcmp.
andreas_kupriesplain2006-09-28 03:22:59
Logged In: YES user_id=75003 Fixed, and commited to Head. No backport to 8.4.
dgpplain2006-09-28 21:52:13
Logged In: YES user_id=80530 Something seriously wrong with that patch: % package require Tcl 8.5 version conflict for package "Tcl": have 8.5a5, need 8.5
dgpplain2006-09-28 22:05:41
Logged In: YES
user_id=80530
dgpok, I think I found it
[11:05]dgpCallers assume CompareVersions() returns value
from set {-1, 0, 1}
[11:05]dgpAfter revision, it can return other integers.
dgpplain2006-09-28 22:13:12
Logged In: YES user_id=80530 fix committed.
andreas_kupriesplain2006-09-28 23:02:54
Logged In: YES user_id=75003 Thanks for noting the problem and fixing it. In my defense, this was not caught when I ran the testsuite. Which however means that we should extend it and convert this problem into an additional testcase.
andreas_kupriesplain2006-09-28 23:11:14
Logged In: YES
user_id=75003
Actually, the error does not happen for me at all. I haven't
updated my sandbox yet to include your fix, and if I do the
'package require Tcl 8.5' I get 8.5a5 returned and no error.
Could it be that the strcmp result is platform dependent ?
And on linux it stays in the set {-1,0,1} ? Wheras your
platform allows any numbers ? Sigh.
So even adding a testcase may not catch the problem on all
platforms :( Still, adding it makes sense for the platforms
which would catch it.
Log in (anonymous is fine) to add a comment.