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

Errors can't be used in a multithreaded environment #114

Open
mmartinv opened this issue Jan 30, 2025 · 1 comment
Open

Errors can't be used in a multithreaded environment #114

mmartinv opened this issue Jan 30, 2025 · 1 comment

Comments

@mmartinv
Copy link

I am upgrading to v0.5.2 version and it looks like there are some changes that make the use of CoseError not possible in multithreaded environments. The actual error I get is:

error[E0277]: `(dyn std::error::Error + 'static)` cannot be sent between threads safely
  --> db/src/postgres.rs:34:42
   |
34 |             contents: ov.serialize_data()?,
   |                                          ^ `(dyn std::error::Error + 'static)` cannot be sent between threads safely
   |
   = help: the trait `Send` is not implemented for `(dyn std::error::Error + 'static)`
   = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
   = note: required for `Unique<(dyn std::error::Error + 'static)>` to implement `Send`
note: required because it appears within the type `Box<(dyn std::error::Error + 'static)>`
  --> /builddir/build/BUILD/rust-1.84.0-build/rustc-1.84.0-src/library/alloc/src/boxed.rs:233:12
note: required because it appears within the type `aws_nitro_enclaves_cose::error::CoseError`
  --> /home/mmartinv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-nitro-enclaves-cose-0.5.2/src/error.rs:16:10
   |
16 | pub enum CoseError {
   |          ^^^^^^^^^
note: required because it appears within the type `fdo_data_formats::Error`
  --> /home/mmartinv/devel/src/github.com/fdo-rs/worktrees/update-aws-nitro-enclaves-cose/data-formats/src/errors.rs:21:10
   |
21 | pub enum Error {
   |          ^^^^^
   = note: required for `anyhow::Error` to implement `From<fdo_data_formats::Error>`
   = note: required for `Result<(), anyhow::Error>` to implement `FromResidual<Result<Infallible, fdo_data_formats::Error>>`
mmartinv added a commit to mmartinv/aws-nitro-enclaves-cose that referenced this issue Jan 30, 2025
Make it safe to send CoseErrors between threads

Fixes: awslabs#114

Signed-off-by: Miguel Martín <[email protected]>
@mmartinv
Copy link
Author

mmartinv commented Jan 30, 2025

@eugkoira @petreeftime could you please take a look at the proposed fix? does it make sense? I am pinging blindly, not sure if you are the right people :(

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

1 participant