profile
viewpoint

samrat/ecstatic 20

ecstatic creates static web pages and blog posts from Hiccup templates and Markdown.

samrat/jopbox 11

A Clojure library to work with the Dropbox API

samrat/happy-dashboard 9

Source code for http://smingh.org/posts/2013-07-04-clojure-websockets-with-http-kit/

samrat/elm-fractals 7

Drawing fractals with Elm.

nilenso/time-tracker-web-nxt 5

A time tracker application brought to you by ClojureScript with all the goodness of re-frame. This is the front-end to https://github.com/nilenso/time-tracker.

samrat/Instamator 4

Generate feeds(RSS, JSON and text) from your Instagram "likes"

samrat/lorenz-opengl 3

Lorenz System in OpenGL

samrat/double-pendulum 2

Double pendulum demo in C w/ OpenGL

samrat/instafeeder 2

Simple Python script to send your feed subscriptions to Instapaper

samrat/blogengine 1

A really simple blog engine powered by Flask which I created to learn Flask.

push eventsamrat/rug

Samrat Man Singh

commit sha 729372877b86075ac05a0ac2032ff7fb11a58b02

[log] Decorate commit SHAs with the ref's pointing to them

view details

push time in a month

push eventsamrat/rug

Samrat Man Singh

commit sha 98dcbb9db441c09cf9ed76208c4acd4cd5128eef

Remove unnecessary `clone`s

view details

Samrat Man Singh

commit sha 6fc4f5c5c8f29ad6d66c0be91b2ee54f3844a963

[log] impl Iterator for Log, so the struct is consistent with other commands

view details

push time in a month

push eventsamrat/rug

Samrat Man Singh

commit sha 0bea75f4b884ab42c031adaedc00732523de01d4

[log] Support flags to show commits in `oneline` format

view details

push time in a month

push eventsamrat/rug

Samrat Man Singh

commit sha 76d6ad74e2c8a918ee56c031d289ecac037aad9a

Add gotchas to README Also: some cleanup

view details

push time in a month

push eventsamrat/rug

Samrat Man Singh

commit sha 233a829c0a01b06d8804a49fbac04bf0f9091992

[log] Add each_commit method to apply fn on each commit

view details

push time in a month

push eventsamrat/zig

Samrat Man Singh

commit sha 9fd181ff5b7e7c7266515a27c63b2f7a247041d9

std: Change type of `os.exit` param to u32

view details

push time in a month

push eventsamrat/zig

Samrat Man Singh

commit sha bdc89d56c1a34937849af4c2fca1bfc20c493bc2

std: Change type of `os.exit` param to u32

view details

push time in a month

PR opened ziglang/zig

std: Change type of `os.exit` param to u32

Fixes #6342

+2 -2

0 comment

1 changed file

pr created time in a month

create barnchsamrat/zig

branch : exit-u32-status

created branch time in a month

PR opened ziglang/zig

Use std.log in LibcInstallation `parse` instead of taking `stderr`

Fixes #6345

+10 -13

0 comment

2 changed files

pr created time in a month

create barnchsamrat/zig

branch : std-log-libc-installation

created branch time in a month

fork samrat/zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

https://ziglang.org

fork in a month

push eventsamrat/miri

Samrat Man Singh

commit sha 563fb8e43d4c236faeeb9b611294a82ecff93712

Implement dup and close for stdin/stdout/stderr Support F_DUPFD on stdin/stdout/stderr Enable `close`-ing stdin/stdout/stderr For `dup`, check if FD is `File` first If not, clone the appropriate standard IO stream Merge POSIX `close` and `dup` tests into same module Also, add assertion that `write` on a closed FD returns an error. Add `dup` as FileDescriptor trait fn Also: - Fix `close` so it drops `self` instead of reference to it - Remove FD clamping in insert_fd_with_min_fd, since FDs 0-2 can be closed Fix fs_libc tests Make error message when closing stdin/out/err more specific Return io::Result from `FileDescriptor::dup` Change error message when closing stdin/out/err Refactor `FileDescriptor::dup` impl for `FileHandle` Remove empty line

view details

push time in 2 months

pull request commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

Removed the newline and squashed all commits into one.

samrat

comment created time in 2 months

push eventsamrat/miri

David Cook

commit sha 6d323e10324298a8fc7c268079c7999794525a7a

Refactor timespec parsing, improve error handling

view details

David Cook

commit sha 417ac2939a87b84c70f4c8b3c2a343c253a5c5d1

Implement libc::nanosleep shim

view details

Ralf Jung

commit sha 210f18d6c7962ae5125947e89d38cac34c65b6a8

work around rustc optimizations becoming too smart

view details

Ralf Jung

commit sha d9bc19a7b078e75052167496fff3c4d91c7bbd66

test opt-level 2

view details

Ralf Jung

commit sha 088af66f85ef5e885202ad258670936f8edc3c53

better optimization suppression Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>

view details

Ralf Jung

commit sha 029c851d7c0eee03178c96c890ec974262b2ee21

another optimization work-around

view details

Ralf Jung

commit sha 3ba1035d279e0acfc3aaf68e8bd055f2d1ffb205

use standard black_box function

view details

bors

commit sha bb9db2bf8f5562cb90d3643f213972c838c25e6d

Auto merge of #1538 - RalfJung:rustup, r=RalfJung rustup: work around rustc optimizations becoming too smart

view details

Ralf Jung

commit sha 3fdbc0fd3f4e0117d708cac58b35fa841eed19af

fix referenced issue

view details

bors

commit sha 3bc1136600fe8c4339ba327e9d5a7d8d09db6a58

Auto merge of #1539 - RalfJung:issue, r=RalfJung float test case: fix referenced issue

view details

David Cook

commit sha 33e928c9ca456f36ac662657333d6ca046be17bd

Review comments

view details

David Cook

commit sha 597360f49995c3c79f955ff7d61a52082382a412

Simplify read_timespec error handling

view details

David Cook

commit sha 06aaea1d6bd94bb715e558c9a5c9c8af27be8895

Update comment

view details

David Cook

commit sha b06f0d16a9dc66654b4e41f4e57be26e6ef4e302

Use try block instead of closure

view details

bors

commit sha 604a674ea37b302fd605df67be10a24ce94ad0a6

Auto merge of #1536 - divergentdave:nanosleep, r=RalfJung Nanosleep This PR adds a shim for `libc::nanosleep`, (available under -Zmiri-disable-isolation only) which backs `thread::sleep` on Linux and macOS. I started off by extracting the `timespec` parsing from the `pthread_cond_timedwait` shim into a helper method, and adding checks for invalid values. The second commit adds the new shim and a small test. The shim blocks the current thread, and registers a timeout callback to unblock the thread again, using the same method as `pthread_cond_timedwait` does.

view details

Samrat Man Singh

commit sha d4538afe7afb4e949c787edc0361ff837141aac1

Implement dup and close for stdin/stdout/stderr Support F_DUPFD on stdin/stdout/stderr Enable `close`-ing stdin/stdout/stderr For `dup`, check if FD is `File` first If not, clone the appropriate standard IO stream Merge POSIX `close` and `dup` tests into same module Also, add assertion that `write` on a closed FD returns an error. Add `dup` as FileDescriptor trait fn Also: - Fix `close` so it drops `self` instead of reference to it - Remove FD clamping in insert_fd_with_min_fd, since FDs 0-2 can be closed Fix fs_libc tests Make error message when closing stdin/out/err more specific Return io::Result from `FileDescriptor::dup` Change error message when closing stdin/out/err Refactor `FileDescriptor::dup` impl for `FileHandle` Remove empty line

view details

push time in 2 months

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 impl FileDescriptor for FileHandle {         }     } -    fn dup<'tcx>(&mut self) -> InterpResult<'tcx, io::Result<Box<dyn FileDescriptor>>> {-        self-            .as_file_handle()-            .map(|FileHandle { file, writable }|-                 file.try_clone().map(|duplicated|-                                      Box::new(FileHandle { file: duplicated, writable: *writable }) as Box<dyn FileDescriptor>))+    fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {+        self.file+            .try_clone()+            .map(|duplicated|+                 Box::new(FileHandle { file: duplicated, writable: self.writable }) as Box<dyn FileDescriptor>)

That works. Changed this.

samrat

comment created time in 2 months

PullRequestReviewEvent

push eventsamrat/miri

Samrat Man Singh

commit sha 570eef97af0e3f7672969d56d3b1cc2f752239ca

Refactor `FileDescriptor::dup` impl for `FileHandle`

view details

push time in 2 months

push eventsamrat/miri

Samrat Man Singh

commit sha de914a596bcefba501737ff295507640a6af2c30

Change error message when closing stdin/out/err

view details

push time in 2 months

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// ignore-windows: No libc on Windows+// compile-flags: -Zmiri-disable-isolation++// https://github.com/rust-lang/rust/issues/40032

Done

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// ignore-windows: No libc on Windows+// compile-flags: -Zmiri-disable-isolation++// https://github.com/rust-lang/rust/issues/40032++#![feature(rustc_private)]++extern crate libc;++fn main() {+    unsafe {+        libc::close(2); //~ ERROR stdin/stdout/stderr cannot be closed

Removed this test

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 trait FileDescriptor : std::fmt::Debug {     fn read<'tcx>(&mut self, communicate_allowed: bool, bytes: &mut [u8]) -> InterpResult<'tcx, io::Result<usize>>;     fn write<'tcx>(&mut self, communicate_allowed: bool, bytes: &[u8]) -> InterpResult<'tcx, io::Result<usize>>;     fn seek<'tcx>(&mut self, communicate_allowed: bool, offset: SeekFrom) -> InterpResult<'tcx, io::Result<u64>>;-    fn close<'tcx>(&mut self, communicate_allowed: bool) -> InterpResult<'tcx, io::Result<i32>>;+    fn close<'tcx>(self: Box<Self>, _communicate_allowed: bool) -> InterpResult<'tcx, io::Result<i32>> {+        throw_unsup_format!("stdin/stdout/stderr cannot be closed(not supported by Rust)");

Moved these to stdin/out/err impls

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 impl FileDescriptor for FileHandle {         }     } -    fn dup<'tcx>(&mut self) -> InterpResult<'tcx, io::Result<Box<dyn FileDescriptor>>> {-        self-            .as_file_handle()-            .map(|FileHandle { file, writable }|-                 file.try_clone().map(|duplicated|-                                      Box::new(FileHandle { file: duplicated, writable: *writable }) as Box<dyn FileDescriptor>))+    fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {+        self.file+            .try_clone()+            .map(|duplicated|+                 Box::new(FileHandle { file: duplicated, writable: self.writable }) as Box<dyn FileDescriptor>)

It's not able to, for some reason:

   = note: expected enum `std::result::Result<std::boxed::Box<(dyn FileDescriptor + 'static)>, _>`
              found enum `std::result::Result<std::boxed::Box<FileHandle>, _>`
samrat

comment created time in 2 months

PullRequestReviewEvent

push eventsamrat/miri

Samrat Man Singh

commit sha 356c739aa74ce3cd1f48afa7b48b165f78e6e95b

Make error message when closing stdin/out/err more specific

view details

Samrat Man Singh

commit sha 917960db2f4b5751b6b81d6179777ff8ab77685b

Return io::Result from `FileDescriptor::dup`

view details

push time in 2 months

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 impl FileDescriptor for FileHandle {             Ok(Ok(0))         }     }++    fn dup<'tcx>(&mut self) -> InterpResult<'tcx, io::Result<Box<dyn FileDescriptor>>> {+        self+            .as_file_handle()

Oh yeah, missed this while moving this to the trait fn.

samrat

comment created time in 2 months

PullRequestReviewEvent

push eventsamrat/miri

Samrat Man Singh

commit sha a45a005649e357b2d5e627c56b3101f59a122f32

Add `dup` as FileDescriptor trait fn Also: - Fix `close` so it drops `self` instead of reference to it - Remove FD clamping in insert_fd_with_min_fd, since FDs 0-2 can be closed

view details

Samrat Man Singh

commit sha 893251c40ed40c2c1654c8aa16e74c96e1e40773

Fix fs_libc tests

view details

push time in 2 months

create barnchsamrat/miri

branch : wip-dup-fd-changes

created branch time in 2 months

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation++#![feature(rustc_private)]++extern crate libc;++fn main() -> std::io::Result<()> {+    let bytes = b"hello\n";+    unsafe {+        let new_stdout = libc::fcntl(1, libc::F_DUPFD, 0);+        let new_stderr = libc::fcntl(2, libc::F_DUPFD, 0);+        libc::write(new_stdout, bytes.as_ptr() as *const libc::c_void, 6);+        libc::write(new_stderr, bytes.as_ptr() as *const libc::c_void, 6);+    }++    Ok(())+}

Hmm, that makes sense. But since we are not able to actually close the standard IO streams, perhaps this check can stay as it is for the time being?

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation++#![feature(rustc_private)]++extern crate libc;++fn main() -> std::io::Result<()> {+    let bytes = b"hello\n";+    unsafe {+        let new_stdout = libc::fcntl(1, libc::F_DUPFD, 0);+        let new_stderr = libc::fcntl(2, libc::F_DUPFD, 0);+        libc::write(new_stdout, bytes.as_ptr() as *const libc::c_void, 6);+        libc::write(new_stderr, bytes.as_ptr() as *const libc::c_void, 6);+    }++    Ok(())+}

Do we want to change this behaviour?

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation++#![feature(rustc_private)]++extern crate libc;++fn main() -> std::io::Result<()> {+    let bytes = b"hello\n";+    unsafe {+        let new_stdout = libc::fcntl(1, libc::F_DUPFD, 0);+        let new_stderr = libc::fcntl(2, libc::F_DUPFD, 0);+        libc::write(new_stdout, bytes.as_ptr() as *const libc::c_void, 6);+        libc::write(new_stderr, bytes.as_ptr() as *const libc::c_void, 6);+    }++    Ok(())+}

Looks like currently there is no way in miri for FDs 0,1,2 to get reassigned to a file, due to this check:

https://github.com/rust-lang/miri/blob/master/src/shims/posix/fs.rs#L150

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation++#![feature(rustc_private)]++extern crate libc;++fn main() -> std::io::Result<()> {+    let bytes = b"hello\n";+    unsafe {+        libc::write(1, bytes.as_ptr() as *const libc::c_void, 6);+        libc::close(1);+        libc::write(1, bytes.as_ptr() as *const libc::c_void, 6);

Done.

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation

Added this.

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

+// compile-flags: -Zmiri-disable-isolation++#![feature(rustc_private)]++extern crate libc;++fn main() -> std::io::Result<()> {+    let bytes = b"hello\n";+    unsafe {+        libc::write(2, bytes.as_ptr() as *const libc::c_void, 6);+        libc::close(2);+        libc::write(2, bytes.as_ptr() as *const libc::c_void, 6);

Added an assertion for this. And merged this and other tests into a single file.

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx             // thus they can share the same implementation here.             let &[_, _, start] = check_arg_count(args)?;             let start = this.read_scalar(start)?.to_i32()?;-            if fd < MIN_NORMAL_FILE_FD {-                throw_unsup_format!("duplicating file descriptors for stdin, stdout, or stderr is not supported")-            }+             let fh = &mut this.machine.file_handler;-            let (file_result, writable) = match fh.handles.get(&fd) {-                Some(file_descriptor) => {-                    // FIXME: Support "dup" for all FDs(stdin, etc)-                    let FileHandle { file, writable } = file_descriptor.as_file_handle()?;-                    (file.try_clone(), *writable)-                },-                None => return this.handle_not_found(),-            };-            let fd_result = file_result.map(|duplicated| {-                fh.insert_fd_with_min_fd(FileHandle { file: duplicated, writable }, start)-            });-            this.try_unwrap_io_result(fd_result)++            if fd < 3 {+                let dup_fd : Box<dyn FileDescriptor> = match fd {+                    0 => Box::new(io::stdin()),+                    1 => Box::new(io::stdout()),+                    2 => Box::new(io::stderr()),

Made changes so that we check if the FileDescriptor is a File. If not, then we make a copy of stdin/out/err based on FD.

samrat

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx          let fd = this.read_scalar(fd_op)?.to_i32()?; -        if let Some(file_descriptor) = this.machine.file_handler.handles.remove(&fd) {-            // FIXME: Support `close` for all FDs(stdin, etc)-            let FileHandle { file, writable } = file_descriptor.as_file_handle()?;-            // We sync the file if it was opened in a mode different than read-only.-            if *writable {-                // `File::sync_all` does the checks that are done when closing a file. We do this to-                // to handle possible errors correctly.-                let result = this.try_unwrap_io_result(file.sync_all().map(|_| 0i32));-                // Now we actually close the file.-                drop(file);-                // And return the result.-                result-            } else {-                // We drop the file, this closes it but ignores any errors produced when closing-                // it. This is done because `File::sync_all` cannot be done over files like-                // `/dev/urandom` which are read-only. Check-                // https://github.com/rust-lang/miri/issues/999#issuecomment-568920439 for a deeper-                // discussion.-                drop(file);-                Ok(0)-            }+        if let Some(mut file_descriptor) = this.machine.file_handler.handles.remove(&fd) {+            let result = file_descriptor.close(this.machine.communicate)?+            .map(|c| i32::try_from(c).unwrap());

Removed this

samrat

comment created time in 2 months

PullRequestReviewEvent

push eventsamrat/miri

Samrat Man Singh

commit sha 1ff618c857c8428c48828a6ced7b094b2eb6f471

Merge POSIX `close` and `dup` tests into same module Also, add assertion that `write` on a closed FD returns an error.

view details

push time in 2 months

push eventsamrat/miri

Ralf Jung

commit sha cb985670c1997534a0cd1cfee606e81e4fa136dc

make alignment check integer-based by default, and add an option to make it symbolic

view details

Ralf Jung

commit sha 5a579f281d913d7d838413564272fafc23c6c336

document -Zmiri-symbolic-alignment-check

view details

Ralf Jung

commit sha 664706662ff1221e88e70dd5c6ceef391e2528a6

adjust diagnostics to alignment check mode

view details

Ralf Jung

commit sha d4e5943259de7573556711ed6496c409dd754ea3

use real align_offset unless we symbolic alignment check is enabled

view details

Ralf Jung

commit sha 0913653e065896cbbacf164c36673fec48f947d1

make sure we test panic of interpreter-impelemted align_offset

view details

Ralf Jung

commit sha f691e573b242a046b9c411eb8e362b8a0715f07e

tweak alignment check docs

view details

Ralf Jung

commit sha db159b8709dac1cb8adeac91c3257906e55319ec

rustup

view details

Ralf Jung

commit sha 5b1bc4ba94cdbb403388cd7c5b45f5ecf4ccd922

make another test more robust against random alignment

view details

bors

commit sha 066fa629f2db7c248e50b03e5aa38c2c9f07031a

Auto merge of #1513 - RalfJung:int-align, r=RalfJung add option to use force_int for alignment check Fixes https://github.com/rust-lang/miri/issues/1074. Depends on https://github.com/rust-lang/rust/pull/75592.

view details

Ralf Jung

commit sha d5b15297acc5f585b308700d27c0f1420154a14e

forgot to add alignment test loop in one test

view details

bors

commit sha 2d6d73fafe2f087354f7cea37297cd81316cae98

Auto merge of #1517 - RalfJung:align-test, r=RalfJung forgot to add alignment test loop in one test As expected, checking the physical integer address made alignment tests fragile, and I forgot to add the retry loop for this one.

view details

Jubilee Young

commit sha 20942fb3a72b30a69f2ad5775b58b358dabab002

Remove byteorder dependency miri hasn't actually depended on byteorder directly for a while. Let's remove this dependency so Rust also depends less on it.

view details

Ralf Jung

commit sha 237bea2c179adac24e12c190add9d8366192b32d

avoid promotion in alignment test to get different alignment on each try

view details

bors

commit sha 9570008c0b118d13a5cd36e437da2e971f95f067

Auto merge of #1520 - RalfJung:rustup, r=RalfJung avoid promotion in alignment test to get different alignment on each try

view details

Jubilee Young

commit sha f3747b635e90faa5ee02e4207c5ed2bca64be274

Update lockfile

view details

bors

commit sha eb08007fe832c07f731fc804ad1d0c229ddd593b

Auto merge of #1518 - workingjubilee:remove-byteorder, r=RalfJung Remove byteorder dependency miri hasn't actually depended on byteorder directly for a while. Let's remove this dependency so Rust also depends less on it.

view details

Jubilee Young

commit sha 2619b4fa1883b324f56798e37b79efe98e66e642

Bump cargo_metadata to 0.11

view details

bors

commit sha e739b81669bda86a1860e7603b4cf34c51d5e12e

Auto merge of #1521 - workingjubilee:bump-cargo-metadata, r=RalfJung Bump cargo_metadata to 0.11

view details

Ralf Jung

commit sha 3b7f36ef8d9ce4419c643b774b58831ba86b8a8f

emphasize that some flags are unsound to use

view details

bors

commit sha 6b96b17470d3220ff83353fe6ddb892d15d15538

Auto merge of #1522 - RalfJung:readme, r=RalfJung emphasize that some flags are unsound to use

view details

push time in 2 months

pull request commentrust-lang/miri

Implement dup and close for stdin/stdout/stderr

@RalfJung I'll try to address the comments on the PR sometime this weekend. Sorry for having been a bit laggy with follow-ups on this issue(and the last :/ )

samrat

comment created time in 2 months

issue commentrust-lang/rust

`#[forbid(unused_qualifications)]` is incompatible with all builtin derives

Hi @Alexendoo, I don't think I'll be able to devote sufficient time to work on this issue anytime soon.

jonas-schievink

comment created time in 2 months

PR opened rust-lang/miri

Implement dup and close for stdin/stdout/stderr

Implements some of the operations for stdin/out/err, towards #1499

+127 -40

0 comment

8 changed files

pr created time in 2 months

push eventsamrat/miri

Samrat Man Singh

commit sha cf0e1e0cd47060d9724831602a195729d192c5ab

Enable `close`-ing stdin/stdout/stderr

view details

push time in 2 months

create barnchsamrat/miri

branch : more-fd-trait-ops

created branch time in 2 months

issue commentrust-lang/miri

Support more file operations on stdin/stdout/stderr

@RalfJung Yes! I will take this up :)

RalfJung

comment created time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 0c2506411700591f218c03dca19b47388bd80f60

Remove unnecessary whitespace Co-authored-by: Ralf Jung <post@ralfj.de>

view details

push time in 3 months

PR opened rust-lang/miri

Remove lifetime from FileDescriptor trait

Also:

  • Remove type annotate handles declaration instead of every insert.
  • Add note about flush being unnecessary when writing to stderr

Addresses comments in #1495 and #1497

+35 -34

0 comment

2 changed files

pr created time in 3 months

create barnchsamrat/miri

branch : fd-trait-fixes

created branch time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 1069f6b17468a48af5a8ab441bf355ac955f4596

Fix handling of as_file_handle error for `fullfsync`

view details

push time in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

@RalfJung I've opened a PR addressing the comments on error-handling. I'll try to address the rest of the comments in the next couple of days. Does that work?

samrat

comment created time in 3 months

PR opened rust-lang/miri

Bubble up errors from FileDescriptor::as_file_handle

Instead of indicating incorrectly that a handle was not found, return the error from as_file_handle indicating the operation is not supported on the FD.

Addresses some comments in #1495

+54 -67

0 comment

1 changed file

pr created time in 3 months

create barnchsamrat/miri

branch : fix-fs-error-handling

created branch time in 3 months

pull request commentrust-lang/miri

Add `impl FileDescriptor` for stdin, stdout, stderr

@RalfJung I'll open a follow-up PR to address your comments.

samrat

comment created time in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

@RalfJung I'll open a follow-up PR to address your comments.

samrat

comment created time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha bdef57ea45594752f904983effc81fe938fbdfe9

Flush to stdout from FileDescriptor::write for `Stdout` Also, remove unnecessary `-Zmiri-disable-isolation` in test

view details

push time in 3 months

Pull request review commentrust-lang/miri

Add `impl FileDescriptor` for stdin, stdout, stderr

 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx                 let buf = this.read_scalar(buf)?.check_init()?;                 let count = this.read_scalar(n)?.to_machine_usize(this)?;                 trace!("Called write({:?}, {:?}, {:?})", fd, buf, count);-                let result = if fd == 0 {-                    throw_unsup_format!("cannot write to stdin")-                } else if fd == 1 || fd == 2 {-                    // stdout/stderr--                    let buf_cont = this.memory.read_bytes(buf, Size::from_bytes(count))?;-                    // We need to flush to make sure this actually appears on the screen-                    let res = if fd == 1 {-                        // Stdout is buffered, flush to make sure it appears on the screen.-                        // This is the write() syscall of the interpreted program, we want it-                        // to correspond to a write() syscall on the host -- there is no good-                        // in adding extra buffering here.-                        let res = io::stdout().write(buf_cont);-                        io::stdout().flush().unwrap();-                        res-                    } else {-                        // No need to flush, stderr is not buffered.-                        io::stderr().write(buf_cont)-                    };-                    match res {-                        Ok(n) => i64::try_from(n).unwrap(),-                        Err(e) => {-                            this.set_last_error_from_io_error(e)?;-                            -1-                        }-                    }-                } else {-                    this.write(fd, buf, count)?-                };+                let result = this.write(fd, buf, count)?;+                if fd == 1 {+                    io::stdout().flush().unwrap();

Oops! Will move to FileDescriptor::write and restore the comment.

samrat

comment created time in 3 months

Pull request review commentrust-lang/miri

Add `impl FileDescriptor` for stdin, stdout, stderr

 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx     ) -> InterpResult<'tcx, i64> {         let this = self.eval_context_mut(); -        this.check_no_isolation("write")?;-        assert!(fd >= 3);+        if fd >= 3 {+            this.check_no_isolation("write")?;

The FileDescriptor methods won't have this so I don't think it'll be possible to do this check there.

For reads on stdin, @RalfJung suggested forbidding it with isolation: https://github.com/rust-lang/miri/pull/1436#pullrequestreview-419830068

samrat

comment created time in 3 months

PR opened rust-lang/miri

Add `impl FileDescriptor` for stdin, stdout, stderr
  • Use FileDescriptor::read for stdin reads
  • Use FileDescriptor::write for stdout/err writes
  • Handle stdout/err reads in FileDescriptor::read
+104 -72

0 comment

4 changed files

pr created time in 3 months

create barnchsamrat/miri

branch : posix-fs-refactor

created branch time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 79e066fc95c036e64716a4222c580782a9c932c2

Remove unnecessary `clone()` on `writable`

view details

push time in 3 months

PR opened rust-lang/stdarch

Fix typo in doc for `_mm256_permute2f128_si256`

It should be 128 bits, instead of 258 bits: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_permute2f128_si256

+1 -1

0 comment

1 changed file

pr created time in 3 months

create barnchsamrat/stdarch

branch : fix-avx2-typo

created branch time in 3 months

fork samrat/stdarch

Rust's standard library vendor-specific APIs and run-time feature detection

https://doc.rust-lang.org/stable/core/arch/

fork in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

Hmm, in that case I don't think we can remove writable. It seems possible to get the same info from https://doc.rust-lang.org/std/fs/struct.Metadata.html#method.permissions , but it might be simpler to just keep writable.

Did you have any other ideas on how we can remove writable?

samrat

comment created time in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

I'm a bit confused about maybe_sync_file in https://github.com/rust-lang/miri/blob/master/src/shims/posix/fs.rs#L238

Looks like it always returns 0i32 regardless of what the operation fn returns. It should still be okay to attempt to sync for Windows as well, right?

samrat

comment created time in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

@oli-obk It is possible to open a File in read-only mode, so we have to error out on that too.

If we remove the writable, I guess we could always just call File::sync_all and File::set_len(these seem to be the two methods guarded by writable) and let the OS tell us that the Files are readable?

samrat

comment created time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 3386f12eca5db75ee679c5d08fecec88ae99e6a0

Wrap io::Result from `FileDescriptor::{read,write,seek}` in InterpResult The outer InterpResult will be used to indicate that a fn is not implemented for a struct(eg. `write` for Stdin). The inner io::Result is just the result from the read/write/seek.

view details

push time in 3 months

create barnchsamrat/miri

branch : temp-fd-trait-with-options

created branch time in 3 months

Pull request review commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

 struct FileHandle {     writable: bool, } +trait FileDescriptor<'tcx> : std::fmt::Debug {+    fn as_file_handle(&self) -> InterpResult<'tcx, &FileHandle>;++    fn read(&mut self, bytes: &mut [u8]) -> Result<usize, io::Error>;+    fn write(&mut self, bytes: &[u8]) -> Result<usize, io::Error>;

I could change this. What would the appropriate error value be?

Currently in https://github.com/rust-lang/miri/pull/1495/files#diff-560909e2fdd6fac0fb0b832d9470ac7cL481 , we set the error code and return Ok(-1). However, with this PR we don't have a way of setting the error code from FileDescriptor trait object currently.

samrat

comment created time in 3 months

pull request commentrust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

This is what the impl for Stdin would look like:

https://github.com/samrat/miri/commit/2c868a1eaa88c39806a9f2f3a9178782f24c961c#diff-560909e2fdd6fac0fb0b832d9470ac7cR56

(Of course, this is contingent on feedback on this PR)

samrat

comment created time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha e3956f4200184c88f0f6100f15669b1e6639804f

Add FileDescriptor trait to abstract fn's on File's and Std{in,out,err}

view details

Samrat Man Singh

commit sha 2c868a1eaa88c39806a9f2f3a9178782f24c961c

Use `FileDescriptor` to methods to read from STDIN

view details

push time in 3 months

PR opened rust-lang/miri

Add FileDescriptor trait to abstract fn's on File's and Stdin,Stdout,Stderr

Related issue: #1486

Instead of mapping FDs to FileHandle, map them to a FileDescriptor trait object. The goal is to eventually have both FileHandle as well as Stdin, Stdout and Stderr implement this trait so that syscalls involving FDs can handle both Files as well as the standard IO streams.

This PR adds the FileDescriptor trait and an impl for FileHandle. I'll open a separate PR for implementing the trait for the standard IO streams.

+129 -61

0 comment

2 changed files

pr created time in 3 months

create barnchsamrat/miri

branch : fd-trait

created branch time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 2c51d91564364f8d7580660d3db70eb73b28373d

Use `FileDescriptor` to methods to read from STDIN

view details

push time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha ec06abfe4454c074200f91c39bfbf0a22ac039d4

Cleanup

view details

push time in 3 months

push eventsamrat/miri

Samrat Man Singh

commit sha 953877480cfecfbc65e825a45053b1f3d5fdc05f

Implement read, write seek FileDescriptor methods for FileHandle

view details

push time in 3 months

create barnchsamrat/miri

branch : dedup-read

created branch time in 3 months

more