Tk Library Source Code

View Ticket
Login
Ticket UUID: 899211
Title: time-1.3 fails on 64-bit
Type: Bug Version: None
Submitter: dgp Created on: 2004-02-17 23:57:23
Subsystem: ntp Assigned To: andreas_kupries
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2005-08-27 01:00:15
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2005-08-26 18:00:15
Description:
==== time-1.3 time::unixtime FAILED
==== Contents of test case:

    global token
    list [catch {
        set t [time::unixtime $token]
        expr {(0 <= $t) && ($t <= 2147483647)}
    } m] $m

---- Result was:
0 0
---- Result should have been (exact matching):
0 1
==== time-1.3 FAILED


This appears to test that the result
of [time::unixtime] is a positive 32-bit
signed integer?

Should it be so on a 64-bit system?
Maybe this is just testing the wrong thing?
User Comments: andreas_kupries added on 2005-08-27 01:00:13:
Logged In: YES 
user_id=75003

Ok, it was a simple masking problem as we had before with
png and crc. Just restrict the results to 32 bit to get the
correct information. Committed a fix.

andreas_kupries added on 2005-08-27 00:46:06:
Logged In: YES 
user_id=75003

Ok, I found the reason for my data format errors. Yes, I
still had them despite the change in ClientReadEvent. But I
knew that I should have gotten 4 characters, instead of the
actual 7.

In the fake server the _listening_ socket is fconfigured to
binary. The actual socket however is not. After I fixed that
the data format error goes away. So the translation got some
EOL characters and expanded on them.

With this gone I have to report that I now see the same test
failure Don was reporting originally. This I still have to
look into. However with that change maybe even your sparc64
is able to repro the failure ;)

andreas_kupries added on 2005-08-26 23:47:00:
Logged In: YES 
user_id=75003

I have no idea so far regarding the 64bit failures. I will
test your changes to see if that got rid of my 'data format
error'. Maybe I will have a failure, maybe not. I will
report back when I have done this.

patthoyts added on 2005-08-26 08:11:02:
Logged In: YES 
user_id=202636

For RFC868 (time::gettime) the data that we send as a client
is irrelevant as it is only used to get the server to
respond to us. For TCP connections we don't send anything.
For SNTP we should always send 48 bytes.

Added code to the ClientReadEvent to stop reading when we
have received the amount expected for the protocol in use
(ie: 4 bytes for RFC868 and 48 for RFC2030). We should not
really get data in chunks as RFC2030 really only operates
over UDP and the server response is handled as a single UDP
packet.

I wonder why I don't see 64-bit related failures on my sparc64.

andreas_kupries added on 2005-08-26 01:27:40:
Logged In: YES 
user_id=75003

On the machine I am on State(data) aka <token>(data)
contains 7 bytes, and expected were either 4, or 48+. That
is the cause for my error message

Oh, the ClientReadEvent is bad IMHO. The moment it has
received 4 or more characters it stops receiving. This is
bad if the 48+ byte is received in chunks, as the receiver
will stop before it has gotten all data.

But is that the root cause for my test failure. I have to
determine how much data is actually sent. For 32 and 64 bit
systems.

dgp added on 2005-08-26 01:19:17:
Logged In: YES 
user_id=80530


same result with HEAD (8.5a4)

dgp added on 2005-08-26 01:18:33:
Logged In: YES 
user_id=80530

$ /local/src/tcl8.4/unix/tclsh sak.tcl test ntp
Shell is "/local/src/tcl8.4/unix/tclsh"
tcllib tests
Test platform: "Linux-2.2.23-alpha" using Tcl 8.4.11
Tests running in working dir:  /local/src/tcllib
Only running tests that match:  *
Skipping test files that match:  l.*.test
Only sourcing test files that match:  *.test
Tests began at Thu Aug 25 02:16:49 PM EDT 2005
Module: ntp
modules/ntp/time.test
- time    1.2

==== time-1.3 time::unixtime FAILED
==== Contents of test case:

    global token
    list [catch {
        set t [time::unixtime $token]
        expr {(0 <= $t) && ($t <= 2147483647)}
    } m] $m

---- Result was:
0 0
---- Result should have been (exact matching):
0 1
==== time-1.3 FAILED

andreas_kupries added on 2005-08-26 01:16:40:
Logged In: YES 
user_id=75003

To be precise: ActiveTcl 8.4.11.0.172579

andreas_kupries added on 2005-08-26 01:13:46:
Logged In: YES 
user_id=75003

Was the 'still failing' for Tcl 8.4 or 8.5 ?
For 8.4 I now get

modules/ntp/time.test
- time    1.2

==== time-1.3 time::unixtime FAILED
==== Contents of test case:

    global token
    list [catch {
        set t [time::unixtime $token]
        expr {(0 <= $t) && ($t <= 2147483647)}
    } m] $m

---- Result was:
1 {error: data format not recognised}
---- Result should have been (exact matching):
0 1
==== time-1.3 FAILED

A bit different.

andreas_kupries added on 2005-08-26 01:00:37:
Logged In: YES 
user_id=75003

Assigning to myself, having now access to an amd64 machine.

dgp added on 2005-08-26 00:54:03:
Logged In: YES 
user_id=80530

still failing

kot added on 2004-10-08 04:47:12:
Logged In: YES 
user_id=173641

We are seeing this too on FreeBSD-amd64. With tcl-8.4.6. Must 
be a 64-bit vs. signedness thing. The time as returned by 
time::unixtime in the time-1.3 test is something like 
-3197788553. 
 
This is with tcllib-1.6.

dgp added on 2004-10-08 00:47:40:
Logged In: YES 
user_id=80530

still fails in tcllib-1.7 release.

dgp added on 2004-02-27 22:45:07:
Logged In: YES 
user_id=80530


Just ran this test again on
64-bit Linux/Alpha with the
ntp that came as part of
tcllib 1.6.  The test still fails.
The value of $t during failure
is -3217070557

Hope that helps.

patthoyts added on 2004-02-27 06:19:06:
Logged In: YES 
user_id=202636

RFC868, while being quite vague in parts, specifies a 32bit
signed integer as the datum returned to clients. We then
subtract 2208988800 to convert to unix time. As this is
supposed to be current time (we are not dealing with history
here) this should give us something between about 0xc3e8fc4c
and 0xffffffff which means some time during 7 Feb 2036 we
have a bit of a problem with this protocol.

However, I don't know that testing this way is especially
relevant under 64 it platforms (not having such a machine).
Do you actually get correct times out of this?