instacart / truetime.swift Goto Github PK
View Code? Open in Web Editor NEWNTP library for Swift and Objective-C. Get the true time impervious to device clock changes.
Home Page: https://tech.instacart.com/truetime/
License: Apache License 2.0
NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.
Home Page: https://tech.instacart.com/truetime/
License: Apache License 2.0
Hi there.
I am trying to get notified when TrueTime updates its reference date.
I am using following code:
let trueTime = TrueTimeClient.sharedInstance
trueTime.start()
_ = NotificationCenter.default.addObserver(forName: .TrueTimeUpdated,
object: trueTime,
queue: OperationQueue.main,
using: { _ in
print("requested")
})
As result print("requested")
never being called.
Also I sure that referenced date was updated by calling trueTime.referenceTime?.now()
and getting non-nil value.
Am I doing something wrong or there is some bug around this feature?
I am on version 4.1.0 (the latest version available via CocoaPods)
else if atEnd {
let error: NSError
if case let .failure(failure) = result {
error = failure as NSError
} else {
error = NSError(trueTimeError: .noValidPacket)
}
self.finish(ReferenceTimeResult.failure(error))
}
the code getting with error domain:4
Tested with Carthage 0.30.1 and Xcode 10.
Hey there,
first of all, thank you for this great library!
I´m all new to swift and I´m using swift 3. It seems that (maybe only in swift 3) your example for a callback is wrong:
// To block waiting for fetch, use the following:
client.retrieveReferenceTime { result in
switch result {
case let .Success(referenceTime):
let now = referenceTime.now()
case let .Failure(error):
print("Error! \(error)")
}
}
should be with lower case .success
and .failure
I hope here is the right place to post it :)
Thanks again,
Paul
PS: I don´t know how to change the title :(
I noticed that TrueTimeClient.sharedInstance.referenceTime?.now()
returns date with millisecond precision while system call Date()
returns date with microsecond precision.
This behavior can be verified in following way:
print(TrueTimeClient.sharedInstance.referenceTime!.now().timeIntervalSince1970) // Prints 1492622263.091
print(Date().timeIntervalSince1970) // Prints 1492622263.12779
Such loose in precision can be harmful for tasks which depend on timestamp accuracy.
I have encountered a crash in NTPClient caused by non-main threads that appear to use UIKit classes or functions. Generally speaking, it is only safe to use UIKit from the main thread. Calling into UIKit from background threads can cause unpredictable behavior (like crashes!).. Please double check that all of your code (that is not on the main thread) has been explicitly marked as safe to use in the background by Apple.
Encountered on:
iOS 12.3.1
TrueTime.swift version "5.0.3"
Stacktrace
Crashed: com.instacart.ntp.client
0 libdispatch.dylib 0x2274326ac _dispatch_sync_f + 4
1 TrueTime 0x102f09d24 NTPClient.stopQueue() (NTPClient.swift)
2 TrueTime 0x102f0ac60 NTPClient.finish(_:) + 257 (NTPClient.swift:257)
3 TrueTime 0x102f0bfe8 closure #1 in NTPClient.query(addresses:host:) + 224 (NTPClient.swift:224)
4 TrueTime 0x102f03f94 partial apply for closure #2 in static NTPConnection.query(addresses:config:logger:callbackQueue:progress:) + 36 (NTPConnection.swift:36)
5 TrueTime 0x102f04530 partial apply for closure #1 in NTPConnection.complete(_:) + 201 (NTPConnection.swift:201)
6 TrueTime 0x102f088b4 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
7 libdispatch.dylib 0x22742c304 _dispatch_call_block_and_release + 32
8 ??? 0x4f74022742d884 (Missing)
9 ??? 0x704b8227434dd4 (Missing)
10 ??? 0x4f060227435918 (Missing)
11 ??? 0x21f1022743dcc0 (Missing)
12 ??? 0x74c00227628a98 (Missing)
13 ??? 0x3612822762edc4 (Missing)
Tried to use the latest version with cocoapods and this what I get:
NTPExtensions.swift:50:22: 'toIntMax()' is unavailable
NTPExtensions.swift:55:25: 'toIntMax()' is unavailable
NTPExtensions.swift:67:23: 'toIntMax()' is unavailable
TrueTime.swift:54:50: Let 'defaultTimeout' is private and cannot be referenced from a default argument value
TrueTime.swift:55:44: Let 'defaultMaxRetries' is private and cannot be referenced from a default argument value
TrueTime.swift:56:48: Let 'defaultMaxConnections' is private and cannot be referenced from a default argument value
TrueTime.swift:57:44: Let 'defaultMaxServers' is private and cannot be referenced from a default argument value
TrueTime.swift:58:49: Let 'defaultNumberOfSamples' is private and cannot be referenced from a default argument value
TrueTime.swift:59:55: Let 'defaultPollInterval' is private and cannot be referenced from a default argument value
Any ideas what's wrong?
In a previous post you had mentioned that TrueTime should be addressing the issue of drifting. From my understanding about every 8 minutes the code automatically invalidates the old NTP time reference and fetches a new NTP time reference. In the tests I have ran I still get the original time reference when I print referenceTime. The only time the NTP time is updated is when network becomes unreachable then becomes reachable again. Other than implementing the base code found in your readme file:
let client = TrueTimeClient.sharedInstance
client.start()
Then calling: let now = client.referenceTime?.now()
Is there something else I have missed that should start and execute the 8 minute timer to force a new NTP update?
Address sanitizer detects Heap buffer overflow when using TrueTime
I am using Xcode Version 10.0 beta 4 (10L213o)
How to reproduce:
pod 'TrueTime'
to the projectTrueTimeClient.sharedInstance.start()
1116
=================================================================
==8706==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x607000040e30 at pc 0x00010cafe031 bp 0x70000b5ffad0 sp 0x70000b5ffac8
READ of size 1 at 0x607000040e30 thread T2
#0 0x10cafe030 in $S8TrueTime13SocketAddressO7storage4portACSgSPySo09sockaddr_E0VG_s6UInt16VSgtcfC (TrueTime:x86_64+0xb5030)
#1 0x10ca6b478 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_AA13SocketAddressOSg10Foundation4DataVXEfU_ (TrueTime:x86_64+0x22478)
#2 0x10ca6bb1c in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_AA13SocketAddressOSg10Foundation4DataVXEfU_TA (TrueTime:x86_64+0x22b1c)
#3 0x10ca6bc5d in $S10Foundation4DataV8TrueTime13SocketAddressOSgs5Error_pIgndzo_AcGsAH_pIegnrzo_TR (TrueTime:x86_64+0x22c5d)
#4 0x10ca6c4ba in $S10Foundation4DataV8TrueTime13SocketAddressOSgs5Error_pIgndzo_AcGsAH_pIegnrzo_TRTA (TrueTime:x86_64+0x234ba)
#5 0x10dfea17e in $SSlsE3mapySayqd__Gqd__7ElementQzKXEKlF (libswiftCore.dylib:x86_64+0x1f17e)
#6 0x10ca6a6c2 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_ (TrueTime:x86_64+0x216c2)
#7 0x10ca6abf0 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_TA (TrueTime:x86_64+0x21bf0)
#8 0x10ca5dc1d in $SIeg_IeyB_TR (TrueTime:x86_64+0x14c1d)
#9 0x10b7a2105 in __wrap_dispatch_async_block_invoke (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x52105)
#10 0x10ff5a224 in _dispatch_call_block_and_release (libdispatch.dylib:x86_64+0x3224)
#11 0x10ff5b2df in _dispatch_client_callout (libdispatch.dylib:x86_64+0x42df)
#12 0x10ff628b0 in _dispatch_lane_serial_drain (libdispatch.dylib:x86_64+0xb8b0)
#13 0x10ff6351d in _dispatch_lane_invoke (libdispatch.dylib:x86_64+0xc51d)
#14 0x10ff6d659 in _dispatch_workloop_worker_thread (libdispatch.dylib:x86_64+0x16659)
#15 0x110349fd1 in _pthread_wqthread (libsystem_pthread.dylib:x86_64+0x2fd1)
#16 0x110349be8 in start_wqthread (libsystem_pthread.dylib:x86_64+0x2be8)
#17 0x10fffffff (libdyld.dylib):x86_64+0x2ffff)
0x607000040e30 is located 0 bytes to the right of 80-byte region [0x607000040de0,0x607000040e30)
allocated by thread T2 here:
#0 0x10b7a3e53 in __sanitizer_mz_malloc (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x53e53)
#1 0x110200e51 in malloc_zone_malloc (libsystem_malloc.dylib:x86_64+0xfe51)
#2 0x10dae8722 in _CFRuntimeCreateInstance (CoreFoundation:x86_64+0x8e722)
#3 0x10da940a2 in __CFDataInit (CoreFoundation:x86_64+0x3a0a2)
#4 0x10f0f639f in _HostLookup_Master_dispatch_GetAddrInfoCallBack(int, addrinfo*, void*) (CFNetwork:x86_64+0x16739f)
#5 0x11015d0d8 in si_libinfo_addrinfo_callback (libsystem_info.dylib:x86_64+0x130d8)
#6 0x11016f55c in si_async_handle_reply (libsystem_info.dylib:x86_64+0x2555c)
#7 0x11015d25c in getaddrinfo_async_handle_reply (libsystem_info.dylib:x86_64+0x1325c)
#8 0x10f19cacb in DispatchHost::GetAddrAsyncHelper::handle_mach_msg_received(unsigned int) (CFNetwork:x86_64+0x20dacb)
#9 0x10f19cbd8 in invocation function for block in DispatchHost::createAndEnqueuePortSource(unsigned int) (CFNetwork:x86_64+0x20dbd8)
#10 0x10b7a26e5 in __wrap_dispatch_source_set_cancel_handler_block_invoke (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x526e5)
#11 0x10ff5a224 in _dispatch_call_block_and_release (libdispatch.dylib:x86_64+0x3224)
#12 0x10ff5b2df in _dispatch_client_callout (libdispatch.dylib:x86_64+0x42df)
#13 0x10ff5e274 in _dispatch_continuation_pop (libdispatch.dylib:x86_64+0x7274)
#14 0x10ff702e4 in _dispatch_source_invoke (libdispatch.dylib:x86_64+0x192e4)
#15 0x10ff6d659 in _dispatch_workloop_worker_thread (libdispatch.dylib:x86_64+0x16659)
#16 0x110349fd1 in _pthread_wqthread (libsystem_pthread.dylib:x86_64+0x2fd1)
#17 0x110349be8 in start_wqthread (libsystem_pthread.dylib:x86_64+0x2be8)
#18 0x10fffffff (libdyld.dylib):x86_64+0x2ffff)
Thread T2 created by T0 here:
<empty stack>
SUMMARY: AddressSanitizer: heap-buffer-overflow (TrueTime:x86_64+0xb5030) in $S8TrueTime13SocketAddressO7storage4portACSgSPySo09sockaddr_E0VG_s6UInt16VSgtcfC
Shadow bytes around the buggy address:
0x1c0e00008170: fd fd fa fa fa fa 00 00 00 00 00 00 00 00 00 00
0x1c0e00008180: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 fa fa
0x1c0e00008190: fa fa 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
0x1c0e000081a0: 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fd fd
0x1c0e000081b0: fd fd fd fd fd fd fd fd fa fa fa fa 00 00 00 00
=>0x1c0e000081c0: 00 00 00 00 00 00[fa]fa fa fa 00 00 00 00 00 00
0x1c0e000081d0: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 00
0x1c0e000081e0: 00 00 fa fa fa fa 00 00 00 00 00 00 00 00 00 00
0x1c0e000081f0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 fa fa
0x1c0e00008200: fa fa fd fd fd fd fd fd fd fd fd fa fa fa fa fa
0x1c0e00008210: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
2018-07-30 11:03:16.641328+0200 test[8706:749777] =================================================================
2018-07-30 11:03:16.641820+0200 test[8706:749777] ==8706==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x607000040e30 at pc 0x00010cafe031 bp 0x70000b5ffad0 sp 0x70000b5ffac8
2018-07-30 11:03:16.642051+0200 test[8706:749777] READ of size 1 at 0x607000040e30 thread T2
2018-07-30 11:03:16.642260+0200 test[8706:749777] #0 0x10cafe030 in $S8TrueTime13SocketAddressO7storage4portACSgSPySo09sockaddr_E0VG_s6UInt16VSgtcfC (TrueTime:x86_64+0xb5030)
2018-07-30 11:03:16.642473+0200 test[8706:749777] #1 0x10ca6b478 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_AA13SocketAddressOSg10Foundation4DataVXEfU_ (TrueTime:x86_64+0x22478)
2018-07-30 11:03:16.642655+0200 test[8706:749777] #2 0x10ca6bb1c in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_AA13SocketAddressOSg10Foundation4DataVXEfU_TA (TrueTime:x86_64+0x22b1c)
2018-07-30 11:03:16.642864+0200 test[8706:749777] #3 0x10ca6bc5d in $S10Foundation4DataV8TrueTime13SocketAddressOSgs5Error_pIgndzo_AcGsAH_pIegnrzo_TR (TrueTime:x86_64+0x22c5d)
2018-07-30 11:03:16.643040+0200 test[8706:749777] #4 0x10ca6c4ba in $S10Foundation4DataV8TrueTime13SocketAddressOSgs5Error_pIgndzo_AcGsAH_pIegnrzo_TRTA (TrueTime:x86_64+0x234ba)
2018-07-30 11:03:16.643185+0200 test[8706:749777] #5 0x10dfea17e in $SSlsE3mapySayqd__Gqd__7ElementQzKXEKlF (libswiftCore.dylib:x86_64+0x1f17e)
2018-07-30 11:03:16.643363+0200 test[8706:749777] #6 0x10ca6a6c2 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_ (TrueTime:x86_64+0x216c2)
2018-07-30 11:03:16.673345+0200 test[8706:749777] #7 0x10ca6abf0 in $S8TrueTime12HostResolverC7connect33_974D77A194DE214D8271763D66939F35LLyySo9CFHostRefaFyycfU_TA (TrueTime:x86_64+0x21bf0)
2018-07-30 11:03:16.673486+0200 test[8706:749777] #8 0x10ca5dc1d in $SIeg_IeyB_TR (TrueTime:x86_64+0x14c1d)
2018-07-30 11:03:16.673631+0200 test[8706:749777] #9 0x10b7a2105 in __wrap_dispatch_async_block_invoke (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x52105)
2018-07-30 11:03:16.673801+0200 test[8706:749777] #10 0x10ff5a224 in _dispatch_call_block_and_release (libdispatch.dylib:x86_64+0x3224)
2018-07-30 11:03:16.673920+0200 test[8706:749777] #11 0x10ff5b2df in _dispatch_client_callout (libdispatch.dylib:x86_64+0x42df)
2018-07-30 11:03:16.674054+0200 test[8706:749777] #12 0x10ff628b0 in _dispatch_lane_serial_drain (libdispatch.dylib:x86_64+0xb8b0)
2018-07-30 11:03:16.674257+0200 test[8706:749777] #13 0x10ff6351d in _dispatch_lane_invoke (libdispatch.dylib:x86_64+0xc51d)
2018-07-30 11:03:16.674419+0200 test[8706:749777] #14 0x10ff6d659 in _dispatch_workloop_worker_thread (libdispatch.dylib:x86_64+0x16659)
2018-07-30 11:03:16.674580+0200 test[8706:749777] #15 0x110349fd1 in _pthread_wqthread (libsystem_pthread.dylib:x86_64+0x2fd1)
2018-07-30 11:03:16.674705+0200 test[8706:749777] #16 0x110349be8 in start_wqthread (libsystem_pthread.dylib:x86_64+0x2be8)
2018-07-30 11:03:16.674876+0200 test[8706:749777] #17 0x10fffffff (libdyld.dylib):x86_64+0x2ffff)
2018-07-30 11:03:16.675056+0200 test[8706:749777]
2018-07-30 11:03:16.675188+0200 test[8706:749777] 0x607000040e30 is located 0 bytes to the right of 80-byte region [0x607000040de0,0x607000040e30)
2018-07-30 11:03:16.675375+0200 test[8706:749777] allocated by thread T2 here:
2018-07-30 11:03:16.675532+0200 test[8706:749777] #0 0x10b7a3e53 in __sanitizer_mz_malloc (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x53e53)
2018-07-30 11:03:16.675717+0200 test[8706:749777] #1 0x110200e51 in malloc_zone_malloc (libsystem_malloc.dylib:x86_64+0xfe51)
2018-07-30 11:03:16.675934+0200 test[8706:749777] #2 0x10dae8722 in _CFRuntimeCreateInstance (CoreFoundation:x86_64+0x8e722)
2018-07-30 11:03:16.676092+0200 test[8706:749777] #3 0x10da940a2 in __CFDataInit (CoreFoundation:x86_64+0x3a0a2)
2018-07-30 11:03:16.676355+0200 test[8706:749777] #4 0x10f0f639f in _HostLookup_Master_dispatch_GetAddrInfoCallBack(int, addrinfo*, void*) (CFNetwork:x86_64+0x16739f)
2018-07-30 11:03:16.676569+0200 test[8706:749777] #5 0x11015d0d8 in si_libinfo_addrinfo_callback (libsystem_info.dylib:x86_64+0x130d8)
2018-07-30 11:03:16.676790+0200 test[8706:749777] #6 0x11016f55c in si_async_handle_reply (libsystem_info.dylib:x86_64+0x2555c)
2018-07-30 11:03:16.677007+0200 test[8706:749777] #7 0x11015d25c in getaddrinfo_async_handle_reply (libsystem_info.dylib:x86_64+0x1325c)
2018-07-30 11:03:16.677218+0200 test[8706:749777] #8 0x10f19cacb in DispatchHost::GetAddrAsyncHelper::handle_mach_msg_received(unsigned int) (CFNetwork:x86_64+0x20dacb)
2018-07-30 11:03:16.677455+0200 test[8706:749777] #9 0x10f19cbd8 in invocation function for block in DispatchHost::createAndEnqueuePortSource(unsigned int) (CFNetwork:x86_64+0x20dbd8)
2018-07-30 11:03:16.677660+0200 test[8706:749777] #10 0x10b7a26e5 in __wrap_dispatch_source_set_cancel_handler_block_invoke (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x526e5)
2018-07-30 11:03:16.677846+0200 test[8706:749777] #11 0x10ff5a224 in _dispatch_call_block_and_release (libdispatch.dylib:x86_64+0x3224)
2018-07-30 11:03:16.678079+0200 test[8706:749777] #12 0x10ff5b2df in _dispatch_client_callout (libdispatch.dylib:x86_64+0x42df)
2018-07-30 11:03:16.678247+0200 test[8706:749777] #13 0x10ff5e274 in _dispatch_continuation_pop (libdispatch.dylib:x86_64+0x7274)
2018-07-30 11:03:16.678527+0200 test[8706:749777] #14 0x10ff702e4 in _dispatch_source_invoke (libdispatch.dylib:x86_64+0x192e4)
2018-07-30 11:03:16.678752+0200 test[8706:749777] #15 0x10ff6d659 in _dispatch_workloop_worker_thread (libdispatch.dylib:x86_64+0x16659)
2018-07-30 11:03:16.679084+0200 test[8706:749777] #16 0x110349fd1 in _pthread_wqthread (libsystem_pthread.dylib:x86_64+0x2fd1)
2018-07-30 11:03:16.679400+0200 test[8706:749777] #17 0x110349be8 in start_wqthread (libsystem_pthread.dylib:x86_64+0x2be8)
2018-07-30 11:03:16.679615+0200 test[8706:749777] #18 0x10fffffff (libdyld.dylib):x86_64+0x2ffff)
2018-07-30 11:03:16.679939+0200 test[8706:749777]
2018-07-30 11:03:16.680181+0200 test[8706:749777] Thread T2 created by T0 here:
2018-07-30 11:03:16.680497+0200 test[8706:749777] <empty stack>
2018-07-30 11:03:16.680701+0200 test[8706:749777]
2018-07-30 11:03:16.680903+0200 test[8706:749777] SUMMARY: AddressSanitizer: heap-buffer-overflow (TrueTime:x86_64+0xb5030) in $S8TrueTime13SocketAddressO7storage4portACSgSPySo09sockaddr_E0VG_s6UInt16VSgtcfC
2018-07-30 11:03:16.681081+0200 test[8706:749777] Shadow bytes around the buggy address:
2018-07-30 11:03:16.681244+0200 test[8706:749777] 0x1c0e00008170: fd fd fa fa fa fa 00 00 00 00 00 00 00 00 00 00
2018-07-30 11:03:16.681412+0200 test[8706:749777] 0x1c0e00008180: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 fa fa
2018-07-30 11:03:16.681599+0200 test[8706:749777] 0x1c0e00008190: fa fa 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
2018-07-30 11:03:16.681801+0200 test[8706:749777] 0x1c0e000081a0: 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fd fd
2018-07-30 11:03:16.681977+0200 test[8706:749777] 0x1c0e000081b0: fd fd fd fd fd fd fd fd fa fa fa fa 00 00 00 00
2018-07-30 11:03:16.682142+0200 test[8706:749777] =>0x1c0e000081c0: 00 00 00 00 00 00[fa]fa fa fa 00 00 00 00 00 00
2018-07-30 11:03:16.682310+0200 test[8706:749777] 0x1c0e000081d0: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 00
2018-07-30 11:03:16.682484+0200 test[8706:749777] 0x1c0e000081e0: 00 00 fa fa fa fa 00 00 00 00 00 00 00 00 00 00
2018-07-30 11:03:16.682687+0200 test[8706:749777] 0x1c0e000081f0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 fa fa
2018-07-30 11:03:16.682886+0200 test[8706:749777] 0x1c0e00008200: fa fa fd fd fd fd fd fd fd fd fd fa fa fa fa fa
2018-07-30 11:03:16.683049+0200 test[8706:749777] 0x1c0e00008210: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fd fd
2018-07-30 11:03:16.683203+0200 test[8706:749777] Shadow byte legend (one shadow byte represents 8 application bytes):
2018-07-30 11:03:16.683334+0200 test[8706:749777] Addressable: 00
2018-07-30 11:03:16.683516+0200 test[8706:749777] Partially addressable: 01 02 03 04 05 06 07
2018-07-30 11:03:16.683660+0200 test[8706:749777] Heap left redzone: fa
2018-07-30 11:03:16.683805+0200 test[8706:749777] Freed heap region: fd
2018-07-30 11:03:16.684006+0200 test[8706:749777] Stack left redzone: f1
2018-07-30 11:03:16.684197+0200 test[8706:749777] Stack mid redzone: f2
2018-07-30 11:03:16.684367+0200 test[8706:749777] Stack right redzone: f3
2018-07-30 11:03:16.684506+0200 test[8706:749777] Stack after return: f5
2018-07-30 11:03:16.684679+0200 test[8706:749777] Stack use after scope: f8
2018-07-30 11:03:16.684823+0200 test[8706:749777] Global redzone: f9
2018-07-30 11:03:16.684986+0200 test[8706:749777] Global init order: f6
2018-07-30 11:03:16.685159+0200 test[8706:749777] Poisoned by user: f7
2018-07-30 11:03:16.685316+0200 test[8706:749777] Container overflow: fc
2018-07-30 11:03:16.685470+0200 test[8706:749777] Array cookie: ac
2018-07-30 11:03:16.685632+0200 test[8706:749777] Intra object redzone: bb
2018-07-30 11:03:16.685775+0200 test[8706:749777] ASan internal: fe
2018-07-30 11:03:16.685965+0200 test[8706:749777] Left alloca redzone: ca
2018-07-30 11:03:16.686145+0200 test[8706:749777] Right alloca redzone: cb
2018-07-30 11:03:16.686331+0200 test[8706:749777]
==8706==ABORTING
Warning: hit breakpoint while running function, skipping commands and conditions to prevent recursion.AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
(lldb) thread info -s
thread #3: tid = 0xb70d1, 0x000000010b7ab810 libclang_rt.asan_iossim_dynamic.dylib`__asan::AsanDie(), queue = 'com.instacart.dns.host', stop reason = Heap buffer overflow
{
"access_size" : 1,
"access_type" : 0,
"address" : 106034152869424,
"description" : "heap-buffer-overflow",
"instrumentation_class" : "AddressSanitizer",
"pc" : 4507820081,
"stop_type" : "fatal_error"
}
(lldb)
It seems that if retrieveReferenceTimeWithSuccess:failure:
is called while internet is offline it does not reattempt when it comes online? How is it expected to behave with reachability events?
I am using Truetime for quite a time. Recently I updated my xcode to 10.2 which required updating the pods with Swift 3.
When I run pod update, all pods get updated except TrueTime. And this error comes up
Result
does not specify a Swift version and none of the targets (MY_APP_NAME
) integrating it have theSWIFT_VERSION
attribute set. Please contact the author or set theSWIFT_VERSION
attribute in at least one of the targets that integrate this pod.TrueTime
does not specify a Swift version and none of the targets (MY_APP_NAME
) integrating it have theSWIFT_VERSION
attribute set. Please contact the author or set theSWIFT_VERSION
attribute in at least one of the targets that integrate this pod.
Also I have tested it on a new project but it gives same issue.
Please note that this issue comes up only on Objective C projects and not on Swift projects.
Trying to use this pod with objc/XCode9
I get the following error.
Can you please provide a new compatible version ?
The targets “Result” and “TrueTime” contains source code developed with Swift 2.x. Xcode 9 does not support building or migrating Swift 2.x targets.
Use Xcode 8.x to migrate the code to Swift 3.
I was about to try this in my app, but when i try to run the sample app it returns nil whenever I try to get client.referenceTime?.now()
. Am I missing something. tried both cartage and pod both returning the same.
Hi,
I'm recently starting using your library. Now this kind of crash logs are coming from Crashlytics:
Crashed: com.instacart.ntp.connection
0 TrueTime 0x100a30e08 TFFC8TrueTime13NTPConnectionP33_2A79C9048389EB5D5F57E571231D0EE311requestTimeFT_T_U_FT_T + 34
1 libswiftFoundation.dylib 0x10122ea08 _TFV10Foundation4Data15withUnsafeBytesu0_rfzFzGSPq__xx + 176
2 TrueTime 0x100a34c5c TTSf4g_g_n___TFFC8TrueTime13NTPConnectionP33_2A79C9048389EB5D5F57E571231D0EE314handleResponseFV10Foundation4DataT_U_FT_T + 228
3 TrueTime 0x100a3473c TPA__TFFC8TrueTime13NTPConnectionP33_2A79C9048389EB5D5F57E571231D0EE314handleResponseFV10Foundation4DataT_U_FT_T + 80
4 libdispatch.dylib 0x1878661fc _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x1878661bc _dispatch_client_callout + 16
6 libdispatch.dylib 0x1878743dc _dispatch_queue_serial_drain + 928
7 libdispatch.dylib 0x1878699a4 _dispatch_queue_invoke + 652
8 libdispatch.dylib 0x1878748d8 _dispatch_queue_override_invoke + 360
9 libdispatch.dylib 0x18787634c _dispatch_root_queue_drain + 572
10 libdispatch.dylib 0x1878760ac _dispatch_worker_thread3 + 124
11 libsystem_pthread.dylib 0x187a6f2a0 _pthread_wqthread + 1288
12 libsystem_pthread.dylib 0x187a6ed8c start_wqthread + 4
App tries to fetch NTP time from this URLs:
let hostUrls: [URL] = [URL(string: "pool.ntp.org")!, URL(string: "time.apple.com")!]
I couldn't find out the reason of the crash. Could you help me, please?
Hey, i was wondering if it is possible to set your servers yourself?
I would like to retrieve the same UTC time format each time since i need to sort by timestamps. Or does TrueTime already retrieve the same format/zone each time?
Thanks for the library, it seems kinda easy to use :)
Im working on the swift version of an App. We have used TTRx in Android as follows:
...
trueTime.withLoggingEnabled(true)
.withServerResponseDelayMax(delay)
.withConnectionTimeout(timeout)
.withRetryCount(retries)
.withSharedPreferences(context)
...
I´m unable to find equivalent options in the Swift version.
Do they exist? Is there an example or documentation on those functions?
Any help is highly appreciated,
Paul
My class will initial TrueTimeClient object in class init(),
it will start every time, but it can not start second time,
how to detect client is started ?
Current use version 3.1.0
installing the app always goes to failure block
never comes to success block
Error! Error Domain=com.instacart.TrueTimeErrorDomain Code=2 UserInfo={NSLocalizedDescription=The connection timed out.}
this will log every time
I was unable to install the library via cocoapods. I am using XCode 8 and Swift 3. It says "[!] Unable to find a specification for TrueTime (~> 4.0)
"
I implemented trueTime into my swift project and found that when the time was changed in the settings it did not affect the trueTime time, which is exactly what I want. However, when I closed the app and changed the time manually then went back in the trueTime time had changed. Am I implementing it incorrectly? Currently, I am starting the connection in view did load and checking for the time on a one-second timer?
Hey,
Just wondering if there is a similar library for web?
Thanks.
In TrueTime xcodeproj, the iOS framework target has:
Base SDK: No SDK
Supported Platforms: macOS
I believe this should be:
Base SDK: Latest iOS
Supported Platforms: iOS
The architectures change from intel to arm when those are properly configured.
Is the time association persisted to disk in case the user later opens the app while disconnected from the internet?
I have tried this on several projects, and tried reverting to 4.2.0 branch. But every time when I turn this code
[client startWithPool:@[@"time.apple.com"] port:123];
[client fetchIfNeededWithSuccess:^(NTPReferenceTime *referenceTime) {
NSLog(@"True time: %@", [referenceTime now]);
} failure:^(NSError *error) {
NSLog(@"+++ truetime fetch response failure! %@", error);
}];
I get this error
com.instacart.TrueTimeErrorDomain Code=2 "The connection timed out."
@msanders
self.init(whole: ValueType(UInt64(time.tv_sec + secondsFrom1900To1970)),
'+' is deprecated, mixed type addition is deprecated. please use explicit type conversion
First, let me say that this is great!
The Android RX version can be subscribed to so that a function gets called every time (or at least the first time) a new "true time" is established. Is something like that possible in the iOS version? If not, what's the best way to do it?
Also, is the iOS version "full NTP" (instead of SNTP) like the Android RX version? If not, are there plans for that?
Thanks!
plz upload 5.0.0 in cocopods
Hello, I would like to use TrueTime using Cocoapods since it looks like a great library! However, it's swift-3 branch is not accessible through cocoapods. Will this be fixed in the near future?
(This issue was edited: it previously was about the 'Result' dependency not being swift 3 compatible yet, but I discovered that was not the issue. My apologies...)
Hi,
After the update to Swift 4.0 I'm getting trouble retrieving the value from
NSDate *now = [[client referenceTime] now];
The compiler says:
No visible @interface for 'NTPReferenceTime' declares the selector 'now'
If I put an @objc
on the now property everything will work.
I'm wondering if I did something wrong with the setup or if the @objc
is really needed.
Thanks
this line crashes:
self.init(whole: ValueType(UInt64(time.tv_sec + secondsFrom1900To1970)),
in
extension NTPTimevalConvertible {
init(timeSince1970 time: timeval) {
precondition(time.tv_sec >= 0 && time.tv_usec >= 0, "Time must be positive \(time)")
self.init(whole: ValueType(UInt64(time.tv_sec + secondsFrom1900To1970)),
fraction: ValueType(UInt64(time.tv_usec) * UInt64(1<<32 / USEC_PER_SEC)))
}
...
}
note:
private let secondsFrom1900To1970: Int64 = ((365 * 70) + 17) * 24 * 60 * 60
When using TrueTime in Xcode I have been receiving the following warning:
'+' is deprecated: Mixed-type addition is deprecated. Please use explicit type conversion.
The warning is found in: NTPExtensions.swift
on line: 62. The original code for that line is:
self.init(whole: ValueType(UInt64(time.tv_sec + secondsFrom1900To1970)),
By defining each side if the equation with UInt64()
the warning disappears.
The new code should look like this:
self.init(whole: ValueType(UInt64(time.tv_sec) + UInt64(secondsFrom1900To1970)),
I hope this simple change is beneficial to making the overall code and developer experience even better.
We are getting this kind of crash reports via Fabric after building app with Xcode 9.1 , TrueTime version: 4.1.0. Crashes occurred in iPhone 5c devices only.
Is this related to #37 and does latest version solve the problem?
Crashed: com.instacart.ntp.connection
0 TrueTime 0xef6f6c _T08TrueTime13NTPConnectionC07requestB033_2A79C9048389EB5D5F57E571231D0EE3LLyyFyycfU_Tf4g_n + 124
1 TrueTime 0xef6e40 _T08TrueTime13NTPConnectionC07requestB033_2A79C9048389EB5D5F57E571231D0EE3LLyyFyycfU_TA + 20
2 TrueTime 0xf09ec4 _T0Ix_IyB_TR + 36
3 libdispatch.dylib 0x1d1f9797 _dispatch_call_block_and_release + 10
4 libdispatch.dylib 0x1d20659d _dispatch_queue_serial_drain + 854
5 libdispatch.dylib 0x1d1fcb71 _dispatch_queue_invoke + 886
6 libdispatch.dylib 0x1d206a1f _dispatch_queue_override_invoke + 282
7 libdispatch.dylib 0x1d2081b5 _dispatch_root_queue_drain + 326
8 libdispatch.dylib 0x1d20800f _dispatch_worker_thread3 + 106
9 libsystem_pthread.dylib 0x1d3ae87d _pthread_wqthread + 1040
10 libsystem_pthread.dylib 0x1d3ae45c start_wqthread + 8
I integrated SDK manually and it is working on simulator. But when I run it on device it gives following error
Could not find module 'TrueTime' for architecture 'arm64'; found: x86_64
So, Could you please update the SDK to supports 64-bit architecture.
I added TrueTime to my project, using Carthage.
I did not add the folder "Checkouts" to source control.
Steps to reproduce:
Expected:
Reality:
Troubleshooting: if the file Sources/CTrueTime/*.h stays in the "Checkouts" folder, everything is fine. If it is not, the CTrueTime module can not build.
This module currently declares a dependency on Result version 4.0 in the podspec. However, this is out-of-sync with the Cartfile, which doesn't pin a specific version. Result has since been updated to 4.1, and Result 4.0 doesn't compile with Xcode 10.2 and Swift 5. Other modules can't depend on this project via CocoaPods and use Swift 5 until the podspec is updated to either not depend on a specific version, or to specifically depend on Result 4.1. Likewise, some dependencies declared in Cartfile.private
have older versions pinned in Cartfile.resolved
, causing them to fail to compile in Xcode 10.2
@msanders
A quick view of the memory debugger shows that this library leaks so much memory
Can you make it work with cocoapods?
Compiling with Swift 4 gives errors .
I'm trying to integrate True Time in my Obj-c .framework
I manually added the files to my project but I have this issue on build
Check dependencies
Swift is not supported for static libraries.
Is there any way to avoid this issue or is there an Obj-c version of this library?
Thanks.
Just calling TrueTimeClient.sharedInstance
is leading to a app-crash every-time I'm testing it... Is there a simple way to fix this issue?
import TrueTime
let YourClass: yclass = yclass()
public class yclass {
public init() {
}
func initialize() {
let client = TrueTimeClient.sharedInstance // --> error
}
}
Any help would be VERY appreciated.
There's a pause function, it seems to stop the polling timer and halts reachability which is what I’d like to do when my app is backgrounded. Unfortunately there doesn't appear to be a way to resume the poll timer, since the start function ultimately asserts that the reachability callback hasn’t been already initialised.
It’d be great if either the library (optionally) responded to UIApplicationDidEnterBackground
/ UIApplicationWillEnterForeground
events, or you could provide a method of resuming from a paused state. Thank you.
Hey. I got this weird issues testing the demo iOS application
Issue in Script:
framework module TrueTime {
umbrella header "TrueTime.h" // *Umbrella header 'TrueTime.h' not found*
export *
module * { export * }
}
module TrueTime.__Swift {
exclude header "TrueTime-Swift.h"
}
Compiler error:
umbrella header 'TrueTime.h' not found
umbrella header "TrueTime.h"
^
<unknown>:0: error: could not build Objective-C module 'TrueTime'
Does anyone know how to get rid of the error?
I tested version 3.1.0, but I had some compilation errors.
Hello,
How can I change url to another after started?
ex.
let client = TrueTimeClient.sharedInstance
let url = URL(string:"tme.apple.com")
client.start(hostURLs: [url!])
let url2 = URL(string:"time.ntp.com")
client.start(hostURLs: [url2!])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.