If an error code can not be recognized by cuGetErrorString, errStr remains null and causes crashing at DP() printing.
Protect this case.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I've noticed this happens at the end of the program when Libomptarget is being unregistered. It'd be nice to know what causes this but checking the case is definitely better than crashing.
The root cause is a known issue and I put up a bug report to track the status.
https://bugs.llvm.org/show_bug.cgi?id=47595
Anyway, this patch should be sufficient for users at the moment.
I think the errStr is only NULL on when it returns CUDA_FAILURE so it would be redundant.
After a bit more experiment, the return status of cuGetErrorString can be more than CUDA_SUCCESS, CUDA_ERROR_INVALID_VALUE.
In this particular case when the CUDA is deinitialized, the error code cannot be translated by cuGetErrorString any more.
So now only print errStr with CUDA_SUCCESS.
Treat CUDA_ERROR_INVALID_VALUE different from generic !=CUDA_SUCCESS