Skip to content
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

Support SystemTime with enabled isolation #3740

Closed
newpavlov opened this issue Jul 8, 2024 · 4 comments
Closed

Support SystemTime with enabled isolation #3740

newpavlov opened this issue Jul 8, 2024 · 4 comments

Comments

@newpavlov
Copy link
Contributor

newpavlov commented Jul 8, 2024

Right now MIRI with enabled isolation fails in code which uses SystemTime::now() with the following error:

error: unsupported operation: `clock_gettime` with `REALTIME` clocks not available when isolation is enabled
   --> /home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/time.rs:130:22
    |
130 |         cvt(unsafe { libc::clock_gettime(clock, t.as_mut_ptr()) }).unwrap();
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `clock_gettime` with `REALTIME` clocks not available when isolation is enabled
    |

It means that most loggers will trigger this error. In some cases it's possible to work around this by disabling timestamps, but ideally it would work out of the box.

MIRI already has emulation of monotonic clocks. I think it could be used to emulate sytem time as well by re-interpreting the monotonic clock as UNIX timestamp, i.e. MIRI tests would see timestamps for 1970-01-01.

@RalfJung
Copy link
Member

RalfJung commented Jul 8, 2024

We quite deliberately did not do that as it seemed even more confusing than the fake monotonic clock. The intended reaction to a program using SystemTime is -Zmiri-disable-isolation.

(Also, it's Miri, not MIRI. ;)

@newpavlov newpavlov closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2024
@RalfJung
Copy link
Member

RalfJung commented Jul 8, 2024

FWIW if you have a good motivation for why you want this with isolation enabled, we could be persuaded. I just stated our reasoning for not having done this already. :)

@newpavlov
Copy link
Contributor Author

newpavlov commented Jul 8, 2024

It's just a matter of convenience. It would be nice in my opinion to have this feature, but I understand your position above. I've asked the logger crate which we use in our tests to add support for Instant-based timestamps, which is an alternative way to resolve this.

Also, it's Miri, not MIRI.

I always thought it's an abbreviation of "Mid-level Intermediate Representation Interpreter". :)

@RalfJung
Copy link
Member

RalfJung commented Jul 8, 2024

I always thought it's an abbreviation of "Mid-level Intermediate Representation Interpreter". :)

That is indeed the origin of the name, but we don't write it in all-caps. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants