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

Rustup to "rustc 1.58.0-nightly (efd048394 2021-10-20)" #55

Merged
merged 7 commits into from
Feb 12, 2024

Conversation

nstilt1
Copy link
Contributor

@nstilt1 nstilt1 commented Dec 23, 2023

Fixes #19
based on #10

I was able to find 2 specific nightly commits that caused some of the changes:

  • eec856b
    • this one removed sym::send_trait and switched usage to use sym::Send
  • db9fea5
    • this one eliminated .krate() from hir().krate().visit_all_item_likes() and hir().krate().items()

This update might make it a little easier for the next update... but nightly rust really does change nightly.

@nstilt1
Copy link
Contributor Author

nstilt1 commented Dec 23, 2023

Well. It doesn't seem to completely work. ./test.py works, but cargo rudra and docker-cargo-rudra ./ ./rudra-reports doesn't show any log files. Will try the debug version

@nstilt1 nstilt1 marked this pull request as draft December 23, 2023 19:06
@nstilt1
Copy link
Contributor Author

nstilt1 commented Dec 23, 2023

Hmm... maybe I was just expecting a log file to be generated, but I suppose it only does that when it finds something. I tried it out on rust-sha v1.0.3 and got these results

$ cargo rudra

rust-sha$ cargo rudra
2023-12-23 16:39:49.854682 |INFO | [rudra-progress] Running cargo rudra
2023-12-23 16:39:51.728205 |INFO | [rudra-progress] Running rudra for target lib:sha
warning: use of deprecated macro `try`: use the `?` operator instead
   --> src/utils.rs:102:23
    |
102 |         let mut len = try!(self.inner.read(&mut self.buf[..]));
    |                       ^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: use of deprecated macro `try`: use the `?` operator instead
   --> src/utils.rs:108:20
    |
108 |             len += try!(reader.read_pad(&mut self.buf));
    |                    ^^^

warning: use of deprecated macro `try`: use the `?` operator instead
   --> src/utils.rs:172:9
    |
172 |         try!(Write::write(buf, &self.suffix[..]));
    |         ^^^

warning: the item `Default` is imported redundantly
   --> src/sha1.rs:330:13
    |
330 |         use std::default::Default;
    |             ^^^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/somedooby/.rustup/toolchains/nightly-2021-10-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:109:13
    |
109 |     pub use super::v1::*;
    |             ------------ the item `Default` is already defined here
    |
    = note: `#[warn(unused_imports)]` on by default

warning: the item `Default` is imported redundantly
   --> src/sha256.rs:379:13
    |
379 |         use std::default::Default;
    |             ^^^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/somedooby/.rustup/toolchains/nightly-2021-10-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:109:13
    |
109 |     pub use super::v1::*;
    |             ------------ the item `Default` is already defined here

warning: the item `Default` is imported redundantly
   --> src/sha512.rs:312:13
    |
312 |         use std::default::Default;
    |             ^^^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/somedooby/.rustup/toolchains/nightly-2021-10-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:109:13
    |
109 |     pub use super::v1::*;
    |             ------------ the item `Default` is already defined here

2023-12-23 16:39:52.571755 |INFO | [rudra-progress] Rudra started
2023-12-23 16:39:52.571921 |INFO | [rudra-progress] SendSyncVariance analysis started
2023-12-23 16:39:52.571935 |INFO | [rudra-progress] SendSyncVariance analysis finished
2023-12-23 16:39:52.571938 |INFO | [rudra-progress] UnsafeDataflow analysis started
2023-12-23 16:39:52.579893 |INFO | [rudra-progress] UnsafeDataflow analysis finished
2023-12-23 16:39:52.579921 |INFO | [rudra-progress] Rudra finished
Error (UnsafeDataflow:/VecSetLen): Potential unsafe dataflow issue in `utils::Digest::to_bytes_len`
-> src/utils.rs:19:5: 24:6
fn to_bytes_len(&mut self, len: usize) -> Vec<u8> {
        let mut bytes: Vec<u8> = Vec::with_capacity(len);
        unsafe { bytes.set_len(len); };
        self.read(&mut bytes[..]).unwrap();
        bytes
    }

Error (UnsafeDataflow:/VecSetLen): Potential unsafe dataflow issue in `utils::PadBlocks::<I, P, F>::fill_buf`
-> src/utils.rs:91:5: 120:6
fn fill_buf(&mut self) -> io::Result<&[u8]> {
        if self.finished {
            if self.buf.len() > self.block_len && self.len > 0 {
                self.len = 0;
                return Ok(&self.buf[self.block_len..self.block_len*2]);
            }
            return Ok(&self.buf[0..0]);
        }
        
        self.buf.clear();
        unsafe { self.buf.set_len(self.block_len); };
        let mut len = try!(self.inner.read(&mut self.buf[..]));
        self.len += len;
            
        if len < self.block_len {
            unsafe { self.buf.set_len(len); };
            let reader: P = (self.padder)(self.len);
            len += try!(reader.read_pad(&mut self.buf));
            //assert_eq!(self.buf.len(), self.block_len);
            self.finished = true;
        }
        
        if len < self.block_len && len > 0 {
            return Err(io::Error::new(
                    io::ErrorKind::BrokenPipe,
                    "unable to read block to end"));
        }
        
        Ok(&self.buf[..self.block_len])
    }

2023-12-23 16:39:52.779513 |INFO | [rudra-progress] cargo rudra finished

$ docker-cargo-rudra ./ ./rudra-report

This is the output of the report

[[reports]]
level = 'Error'
analyzer = 'UnsafeDataflow:/VecSetLen'
description = 'Potential unsafe dataflow issue in `utils::Digest::to_bytes_len`'
location = 'src/utils.rs:19:5: 24:6'
source = """
fn to_bytes_len(&mut self, len: usize) -> Vec<u8> {
        let mut bytes: Vec<u8> = Vec::with_capacity(len);
        unsafe { �[0m�[31mbytes.set_len(len)�[0m; };
        �[0m�[36mself.read(&mut bytes[..])�[0m.unwrap();
        bytes
    }
�[0m"""

[[reports]]
level = 'Error'
analyzer = 'UnsafeDataflow:/VecSetLen'
description = 'Potential unsafe dataflow issue in `utils::PadBlocks::<I, P, F>::fill_buf`'
location = 'src/utils.rs:91:5: 120:6'
source = """
fn fill_buf(&mut self) -> io::Result<&[u8]> {
        if self.finished {
            if self.buf.len() > self.block_len && self.len > 0 {
                self.len = 0;
                return Ok(&self.buf[self.block_len..self.block_len*2]);
            }
            return Ok(&self.buf[0..0]);
        }
        
        self.buf.clear();
        unsafe { �[0m�[31mself.buf.set_len(self.block_len)�[0m; };
        let mut len = try!(�[0m�[36mself.inner.read(&mut self.buf[..])�[0m);
        self.len += len;
            
        if len < self.block_len {
            unsafe { �[0m�[31mself.buf.set_len(len)�[0m; };
            let reader: P = �[0m�[36m(self.padder)(self.len)�[0m;
            len += try!(�[0m�[36mreader.read_pad(&mut self.buf)�[0m);
            //assert_eq!(self.buf.len(), self.block_len);
            self.finished = true;
        }
        
        if len < self.block_len && len > 0 {
            return Err(io::Error::new(
                    io::ErrorKind::BrokenPipe,
                    \"unable to read block to end\"));
        }
        
        Ok(&self.buf[..self.block_len])
    }
�[0m"""

@nstilt1 nstilt1 marked this pull request as ready for review December 23, 2023 22:59
@Qwaz
Copy link
Member

Qwaz commented Dec 27, 2023

Finally a PR for edition 2021 support! Thanks a lot, I'll check this in a few days.

@Qwaz
Copy link
Member

Qwaz commented Jan 10, 2024

Apologies for the long delay. It's in my TODO list, but I've been busy with works and haven't found time to look at it yet.

@nstilt1
Copy link
Contributor Author

nstilt1 commented Feb 9, 2024

I understand. Since this seems to be a pretty important repo, and since it relies heavily on the current state of the compiler... would it make sense for the compiler team to adopt this repo? It seems like they are pretty up to date with their own changes, but I understand that it would take a while just to update it to a current nightly version. I might give it a go at another update, but it is kind of tedious to find every deleted file and every deleted line to try and figure out which new thing replaced the deprecated things. Do you know if there is a more organized record of the nightly changes aside from the commit history?

@Qwaz Qwaz self-assigned this Feb 12, 2024
@Qwaz
Copy link
Member

Qwaz commented Feb 12, 2024

I'm failing to recreate Rudra-PoC bugs with this PR. I'm investigating if there's any semantic difference between tcx.hir().krate().visit_all_item_likes / tcx.hir().krate().items() and tcx.hir().visit_all_item_likes / tcx.hir().items().

Update: The changes look consistent with rust-lang/rust@db9fea5; I'm not sure why Rudra is affected by this change.

@Qwaz
Copy link
Member

Qwaz commented Feb 12, 2024

To my shame, nightly-2021-08-20 already returns different result from nightly-2020-08-26 (the version used in the paper). I should have tested this version more thoroughly. I'll track this as a separate issue and merge this PR.

@Qwaz Qwaz merged commit f484ad8 into sslab-gatech:master Feb 12, 2024
0 of 2 checks passed
@Qwaz
Copy link
Member

Qwaz commented Feb 12, 2024

Do you know if there is a more organized record of the nightly changes aside from the commit history?

I'm afraid to say that I don't know the best way to track this. That's the main reason why it's difficult for me to maintain this repository.

Regarding the suggestion for an adoption, I'm happy to see this forked or maintained by someone else. Rudra project has MIT+APACHE dual license, which should already allow this type of adoption. On the other hand, I'm unsure if it meets the required quality of the compiler team's expectation. There are many rough edges to be polished in Rudra to surpass the "research quality" product 😅

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

Successfully merging this pull request may close these issues.

update compiler-version for edition2021 support
2 participants