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

Consider swallowing errors in deallocation functions #696

Open
jaredhoberock opened this issue Sep 16, 2014 · 2 comments
Open

Consider swallowing errors in deallocation functions #696

jaredhoberock opened this issue Sep 16, 2014 · 2 comments
Labels
thrust For all items related to Thrust.

Comments

@jaredhoberock
Copy link

thrust::system::cuda::free potentially throws an exception, which can lead to multiple exceptions in flight when this function is called from a destructor. This makes it impossible to do correct exception handling.

We should avoid throwing in functions named free or catch and swallow exceptions in destructors. Not sure what the right thing to do is.

@jaredhoberock
Copy link
Author

thrust::system::cuda::free should probably ignore the error returned by cudaFree.

cudaFree will report an error if 1. the error is already set or 2. the pointer given to cudaFree is invalid.

case 1: if the error is already set, the error has probably already been reported via an exception currently in flight.

case 2: if the pointer given to cudaFree is invalid, we can specify that the behavior is undefined, as does std::free.

So it probably makes sense to swallow errors inside of thrust::system::cuda::free. That way, we don't need to try to handle exceptions in every single destructor which may indirectly call this function.

@jrhemstad jrhemstad added the thrust For all items related to Thrust. label Feb 22, 2023
@jrhemstad
Copy link
Collaborator

@jarmak-nv jarmak-nv transferred this issue from NVIDIA/thrust Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thrust For all items related to Thrust.
Projects
Status: No status
Development

No branches or pull requests

2 participants