-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
--trace-time shows incorrect timestamps #15614
Comments
I dug into the code a little bit, and it appears curl is combining the subsecond numbers from the MONOTONIC clock with the hours, minutes, seconds from the REALTIME clock. The MONOTONIC clock doesn't represent walltime and should only be used to calculate durations (time differences). AFAICT, all tracing tools that include timestamps (strace, tcpdump) use the REALTIME clock. See for example the different clocks on my system right now:
|
Are you looking at the latest code? 7.68.0 is almost 5 years old.
|
|
I don't see any place in the code where a monotonic clock time is combined with another time. The only place I can see a inconsistent time being used is if the call to get the monotonic time fails in which case the real time is used, but the time parts aren't mixed and the kinds of things that could go wrong with getting the monotonic time mean that it's unlikely that both would be found in the same log file. I think you're probably just seeing the difference between monotonic time and real time on your system. The change to monotonic time seems to have been made 16 years ago in commit 19479ea and I don't recall this issue being brought up before. It probably doesn't matter much if the trace log is used in isolation, but if you're trying to correlate with external events in other log files, it would make a huge difference. The original change was probably done to avoid problems with internal timeouts, but log timestamping is sufficiently different that it's probably worth switching back to real time for that one. |
Lines 111 to 113 in cb2ae6e
tvnow() uses CLOCK_MONOTONIC if it's enabled. hms_for_sec uses time() internally.
|
See #15614 (comment) - they're actually hours (years) apart. |
I see the issue now. |
To summarize: besides |
Timestamps in trace logs used a mix of realtime and monotonic time sources, leading to fractional seconds carrying wrong values. Use realtime only, so the correct nanoseconds are printed. refs curl#15614
I made #15641 as a fix for this. Would be nice if you could verify that this fixes things for you. |
I did this
When using the
--trace-time
option, curl doesn't print the actual time, but some other time:I expected the following
The timestamps printed by curl shouldn't be ~100ms off from the ones printed by strace.
curl/libcurl version
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
operating system
Ubuntu 20.04
The text was updated successfully, but these errors were encountered: