-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove iana-time-zone
dependency for clock
feature.
#1018
Conversation
32e32e2
to
e93c499
Compare
Sorry, can you explain this a bit more? |
Sure, I updated the background section. |
What do you mean by unstable API? |
Hi Dirkjan, long time no see 😄
I work with Android these days: the problem is that Android is not going to vendor This in turn means that we cannot bump the version of |
Hey Martin, good to see you're doing Rust work inside Google these days! So, now that I have you here -- is there some stable API we could use to get the current timezone on Android? (For context, this was implemented in #756 in order to deal with the complaints from #755. Does the Android libc |
It seems that local timestamp should be the first option and UTC is a fallback. |
Yeah, it's been a lot of fun!
I'll have to ask around to find out what the correct way is to do this.
If you're talking about the From what I can read in |
Hey all, I talked with people about what the recommended way is to handle timezones on Android. The main takeaways are
Does this help a bit? @esheppa, I saw that you were heavily involved in the #756 and so you will probably be interested in this too. |
Hi @djc! |
@mgeisler is the Android libc susceptible to issues like RUSTSEC-2020-0159? If so, you're asking me to move chrono back to an approach where some ways of using chrono can segfault? I think the timeline here is that:
If Android libc is not susceptible to RUSTSEC-2020-0159, we can revert to using libc calls to get the local timezone offset on Android only. If it is, however, I'm inclined to take on responsibility for the use of unstable platform API/surface and consider any (hopefully temporary) breakage from platform changes the fault of the Android platform for not providing a robust way to get the information we need. For the proposed change, it seems to me that people using chrono with @esheppa @pitdicker any thoughts? |
I read the discussion at the time, but never really understood how the problem was fixed. Or rather: Is it really fixed or do we just pretend it is? As I understand it, calling I'll paste some relevant comments. |
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
rust-lang/rust#27970 (comment)
|
I can understand how a crate that depends on internal APIs can be problematic.
In effect on Android
This is very interesting information! And libc
If I understand it right, there would be no way to fully fix this on the libc side. Does the Rust standard library use the same environment lock as libc (haven't checked yet)? Sorry for the rambling, I am just trying to understand the surrounding issues. For the reason behind this PR: Would putting |
Sorry for the wrong comment. |
I've decided I'm going to close this. I don't think it's feasible to make whether Alternative (partial) solutions:
I just checked and there are still two calls to |
@mgeisler - are you using @djc - I like your first dot point - we could even point users toward This can work well if the following cases seem reasonable:
|
Yes, it's my understanding that the C library would "somehow" know how to do this correctly... it knows the local timezone and can give you up to date information about it.
I am not sure what we use or not use in AOSP, sorry. All I know is that In Android, we would like to standardize the library used for system properties and avoid pulling in duplicate functionality for this (duplicate dependencies end up increasing the size of the Android binaries). |
Is the rustutils crate available on crates.io? If there is an interface that other crates can use then maybe iana-time-zone would be open to changing the dependency they use. |
It's not yet available there and open sourcing it was exactly what I was hoping @dshmatkou could help us with. Dmitry works for Android as a 20% contributor and I'm trying to help him make small tactical fixes to the Rust ecosystem 😄 |
Following up a bit more on this, I've had a chat to @nfuller from the Android time team. It seems there are three supported APIs for accessing timezone data on Android: the standard Java ones, ICU4J (also Java), and the libc functions (e.g. There are also some parts of the Android platform that use However, the good news is that it looks like #499 mostly doesn't apply to Android. With this in mind I suggest that we return |
That sounds okay to me. Can you submit a PR to this effect? |
Thanks, will do. |
[Android's libc maintainer here...]
that's not necessarily true. if someone's calling i think if you want to make a "this is fine" argument, it should be along the lines of "messing with environment variables in a multi-threaded program is inherently unsafe already, and calling fwiw, i think it's time i just bit the bullet and added the i don't know how easy it is in rust to say "call this API if it exists", nor whether rust supports NetBSD at all, but this is actually an alternative implementation you can try today if so. (and having a signed-up user would be further motivation for me :-) ) |
@enh-google thanks for getting involved here. Getting a safer API (from NetBSD) out to Android sounds like a good way forward -- would be awesome if you can get other libcs on board. In terms of adopting it in chrono, how do newer libc implementations roll out to the Android installed base? |
Is that true even if the environment variable you're trying to read isn't set beforehand, and isn't affected by the
The trouble with that approach is that it's not the decision the Rust standard library has made. It exposes safe wrappers around |
as they upgrade to newer OS releases. you can find out what release you're on with the NDK's android_get_device_api_level(), though i'm assuming rust has some equivalent of dlsym() or weak symbols + attribute availability so that you can just check whether the function exists at runtime anyway?
yes (though obviously "someone called putenv() and then messed with the pointer" is going to be the most reliable way to break things).
which is another way of saying "they're not actually safe". that would only be safe in a world where everything in your process was written in rust. which -- although it can be the case for a daemon that's part of the OS on Android -- can never be the case for an Android app, because app code is always dlopen()ed into an existing zygote process. so calling the "safe" rust functions isn't safe in reality either. |
So having looked into the NetBSD API a bit more, it would allow us to allocate a |
The NetBSD man page for |
Fair enough, though it would probably also be useful to have a way to get to the current timezone's name. |
Background
I would like to bump
chrono
's version in Android project. Unfortunately,iana-time-zone
dependency of theclock
feature doesn't allow me do it. In case of Androidiana-time-zone
usesandroid_system_properties
crate to look up system properties (this is not a stable API).Solution
Make
iana-time-zone
dependency default for the crate, but remove it from theclock
feature requirements.Alternative
Use
libc
's localtime functionality. This functionality was removed from the crate in pull #499 due to potentialSEGFAULT
.