Skip to content

0.22.0 includes breaking changes #1466

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

Closed
sporksmith opened this issue Jul 13, 2021 · 4 comments
Closed

0.22.0 includes breaking changes #1466

sporksmith opened this issue Jul 13, 2021 · 4 comments

Comments

@sporksmith
Copy link
Contributor

Mostly FYI; fwiw I'm happy with the API change and it wasn't a big deal to fix in our code, but if I understand semver correctly this should be a major version number bump? (I know nobody wants to go from 0 to 1 ;))

Here's our broken build after bumping from 0.21.0 to 0.22.0: https://github.com/shadow/shadow/pull/1508/checks?check_run_id=3057359519

And our fixes: shadow/shadow#1512

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
  --> host/descriptor/pipe.rs:82:29
   |
82 |             Err(nix::errno::EWOULDBLOCK.into())
   |                             ^^^^^^^^^^^ not found in `nix::errno`
   |
help: consider importing this constant
   |
1  | use libc::EWOULDBLOCK;
   |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/descriptor/pipe.rs:115:29
    |
115 |             Err(nix::errno::EWOULDBLOCK.into())
    |                             ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/syscall/unistd.rs:150:34
    |
150 |     if result == Err(nix::errno::EWOULDBLOCK.into()) && !file_flags.contains(FileFlags::NONBLOCK) {
    |                                  ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/syscall/unistd.rs:219:34
    |
219 |     if result == Err(nix::errno::EWOULDBLOCK.into()) && !file_flags.contains(FileFlags::NONBLOCK) {
    |                                  ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `ENOTSUP` in module `nix::errno`
   --> host/syscall_types.rs:324:39
    |
324 |             let default = nix::errno::ENOTSUP;
    |                                       ^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::ENOTSUP;
    |

error[E0425]: cannot find value `ENOTSUP` in module `nix::errno`
   --> host/syscall_types.rs:343:43
    |
343 |                 let default = nix::errno::ENOTSUP;
    |                                           ^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::ENOTSUP;
    |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
  --> host/descriptor/pipe.rs:82:29
   |
82 |             Err(nix::errno::EWOULDBLOCK.into())
   |                             ^^^^^^^^^^^ not found in `nix::errno`
   |
help: consider importing this constant
   |
1  | use libc::EWOULDBLOCK;
   |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/descriptor/pipe.rs:115:29
    |
115 |             Err(nix::errno::EWOULDBLOCK.into())
    |                             ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/syscall/unistd.rs:150:34
    |
150 |     if result == Err(nix::errno::EWOULDBLOCK.into()) && !file_flags.contains(FileFlags::NONBLOCK) {
    |                                  ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `EWOULDBLOCK` in module `nix::errno`
   --> host/syscall/unistd.rs:219:34
    |
219 |     if result == Err(nix::errno::EWOULDBLOCK.into()) && !file_flags.contains(FileFlags::NONBLOCK) {
    |                                  ^^^^^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::EWOULDBLOCK;
    |

error[E0425]: cannot find value `ENOTSUP` in module `nix::errno`
   --> host/syscall_types.rs:324:39
    |
324 |             let default = nix::errno::ENOTSUP;
    |                                       ^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::ENOTSUP;
    |

error[E0425]: cannot find value `ENOTSUP` in module `nix::errno`
   --> host/syscall_types.rs:343:43
    |
343 |                 let default = nix::errno::ENOTSUP;
    |                                           ^^^^^^^ not found in `nix::errno`
    |
help: consider importing this constant
    |
1   | use libc::ENOTSUP;
    |

error[E0119]: conflicting implementations of trait `std::convert::From<nix::errno::Errno>` for type `host::syscall_types::SyscallError`
   --> host/syscall_types.rs:332:1
    |
320 | impl From<nix::Error> for SyscallError {
    | -------------------------------------- first implementation here
...
332 | impl From<nix::errno::Errno> for SyscallError {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `host::syscall_types::SyscallError`

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0119, E0425.
For more information about an error, try `rustc --explain E0119`.
error: could not compile `shadow-rs`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error[E0119]: conflicting implementations of trait `std::convert::From<nix::errno::Errno>` for type `host::syscall_types::SyscallError`
   --> host/syscall_types.rs:332:1
    |
320 | impl From<nix::Error> for SyscallError {
    | -------------------------------------- first implementation here
...
332 | impl From<nix::errno::Errno> for SyscallError {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `host::syscall_types::SyscallError`

error: aborting due to 7 previous errors
@asomers
Copy link
Member

asomers commented Jul 13, 2021

Semver says that a change of this sort would require a major version bump, if we were already above 1.0. Since we aren't, we don't. But the errors about EWOULDBLOCK and ENOTSUP are probably avoidable. Those are defined as aliases for other errnos in C. Nix ought to define both those and the canonical errnos. What arch and platform are you using?

@sporksmith
Copy link
Contributor Author

Semver says that a change of this sort would require a major version bump, if we were already above 1.0.

Ah, I see. Thanks for clarifying :)

What arch and platform are you using?

x86_64. The pasted and linked broken build is on debian 10; I had similar errors locally on ubuntu 20.04.

@sporksmith
Copy link
Contributor Author

After fixing the previous errors, another type of error I ran into were in match expressions, since you can't match on a function (which nix::error::Sys now is). e.g. https://github.com/shadow/shadow/pull/1512/files#diff-232e037a13e7d361a5cb4f584a1aebc787f1b3ced0299c4fd2c26689f1ce2c64L141 :

            let res = nix::unistd::read(inner.command_notifier, &mut buf);
            debug_assert!(match res {
                Ok(8) => true,
                Ok(i) => panic!("Unexpected read size {}", i),
                Err(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => true,
                Err(e) => panic!("Unexpected error {:?}", e),
            }

Not sure there's really a better way to handle it though, since e.g. making nix::Error::Sys a variant of Errno would make Errno recursive, which I don't think is supported.

@asomers
Copy link
Member

asomers commented Jul 14, 2021

Yep. That Sys function is a best-effort backwards-compat shim. I don't think there's any way to improve it.

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