ArrayFire sets a maximum size for error messages coming through the C API to 1024 characters. This is a problem when an error occurs, say, in compileModule() because the stack trace itself takes 896 characters and is printed first. This doesn't leave enough room for the actual error message to be included in the error string.
This could be fixed by increasing the buffer size. A more flexible solution in the long run would be to let the user specify their own buffer and buffer length as parameters of af_get_last_error() (or a new function, to preserve backward compatibility), as is commonly done in C APIs returning strings.
Description
- Additional details regarding the bug:
This is the error we got
af_sum_all failed. (AF error code: 998, message: In function class cuda::Module __cdecl common::compileModule(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,const class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,const class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,const bool)
In file src\backend\cuda\compile_module.cpp:265
NVRTC Error(7): NVRTC_ERROR_BUILTIN_OPERATION_FAILURE
Log:
nvrtc: error: fa
- Did you build ArrayFire yourself or did you use the official installers: official installer for 3.7.2
- Which backend is experiencing this issue: All
- Do you have a workaround: No
- Can the bug be reproduced reliably on your system: Yes (but see below)
- A clear and concise description of what you expected to happen: The whole error message should have been returned.
- Run your executable with AF_TRACE=all and AF_PRINT_ERRORS=1 environment
variables set: Not relevant.
- Screenshot or terminal output of the results: See above.
Reproducible Code and/or Steps
- Steps or code snippet that can reproduce the bug: Unfortunately this error was reported to us by a customer, so I do not know how the error was triggered (especially not knowing the full error message). Nevertheless, the limitation of 1024 characters is pretty clear in the ArrayFire source code:
|
std::min(MAX_ERR_SIZE, static_cast<int>(global_error_string.size())); |
|
static const int MAX_ERR_SIZE = 1024; |
- A full example will allow us to debug and fix the bug faster: See above.
System Information
Please provide the following information:
- ArrayFire version: 3.7.2
- Devices installed on the system: Not relevant
- (optional) Output from the af::info() function if applicable: Not accessible.
- Output from the following scripts: Not accessible.
Checklist
ArrayFire sets a maximum size for error messages coming through the C API to 1024 characters. This is a problem when an error occurs, say, in
compileModule()because the stack trace itself takes 896 characters and is printed first. This doesn't leave enough room for the actual error message to be included in the error string.This could be fixed by increasing the buffer size. A more flexible solution in the long run would be to let the user specify their own buffer and buffer length as parameters of
af_get_last_error()(or a new function, to preserve backward compatibility), as is commonly done in C APIs returning strings.Description
This is the error we got
variables set: Not relevant.
Reproducible Code and/or Steps
arrayfire/src/api/c/error.cpp
Line 21 in 82a8c77
arrayfire/src/backend/common/err_common.hpp
Line 211 in 82a8c77
System Information
Please provide the following information:
Checklist