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

libafl_qemu: Structured error types for reading/writing registers #2210

Closed

Conversation

langston-barrett
Copy link
Contributor

Makes the errors more programatically inspectable, and instances of std::error::Error. Removes the temptation to impl From<String> for errors that wrap these. Can be trivially converted to strings, which is demonstrated in this PR. Does introduce new Copy bounds, but I think this should be fine?

@domenukk domenukk requested a review from rmalmain May 17, 2024 19:37
@rmalmain
Copy link
Collaborator

Thanks for the PR, this looks good to me.
There is no problem with the R and the T bounds being Copy.

@domenukk
Copy link
Member

domenukk commented May 17, 2024

Clippy is not happy

error[E0277]: the trait bound `qemu::WriteRegError<i32, u64>: pyo3::IntoPy<pyo3::Py<pyo3::PyAny>>` is not satisfied
    --> libafl_qemu/src/qemu/mod.rs:1210:13
     |
1210 |             self.qemu.write_reg(reg, val).map_err(PyValueError::new_err)
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `pyo3::IntoPy<pyo3::Py<pyo3::PyAny>>` is not implemented for `qemu::WriteRegError<i32, u64>`, which is required by `qemu::WriteRegError<i32, u64>: pyo3::PyErrArguments`

...

@domenukk
Copy link
Member

CI claims other archs still have some issues, i.e.:

error[E0308]: mismatched types
  --> libafl_qemu/src/arch/mips.rs:95:9
   |
91 |     fn read_return_address<T>(&self) -> Result<T, String>
   |                                         ----------------- expected `Result<T, std::string::String>` because of return type
...
95 |         self.read_reg(Regs::Ra)
   |         ^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<T, String>`, found `Result<_, ReadRegError<Regs>>`
   |
   = note: expected enum `Result<T, std::string::String>`
              found enum `Result<_, qemu::ReadRegError<arch::mips::Regs>>`
help: use the `?` operator to extract the `Result<_, qemu::ReadRegError<arch::mips::Regs>>` value, propagating a `Result::Err` value to the caller
   |
95 |         self.read_reg(Regs::Ra)?
   |                                +

error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
   --> libafl_qemu/src/arch/mips.rs:102:34
    |
102 |         self.write_reg(Regs::Ra, val)
    |              ---------           ^^^ the trait `std::marker::Copy` is not implemented for `T`
    |              |
    |              required by a bound introduced by this call

@domenukk
Copy link
Member

Any news?

@domenukk
Copy link
Member

domenukk commented Jun 3, 2024

Still unhappy

@domenukk domenukk closed this Jun 3, 2024
@domenukk domenukk reopened this Jun 3, 2024
@langston-barrett
Copy link
Contributor Author

Will reopen when I have more time to fix it up!

@domenukk
Copy link
Member

domenukk commented Jun 6, 2024

@rmalmain want to finish this?

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.

None yet

3 participants