-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] fix for std::locale::global interfering with allowlist check #18550
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
[SYCL] fix for std::locale::global interfering with allowlist check #18550
Conversation
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
@@ -428,6 +428,8 @@ void applyAllowList(std::vector<ur_device_handle_t> &UrDevices, | |||
uint32_t DeviceVendorIdUInt = | |||
DeviceImpl.get_info<info::device::vendor_id>(); | |||
std::stringstream DeviceVendorIdHexStringStream; | |||
// To avoid commas or other locale-specific modifications, call imbue(). | |||
DeviceVendorIdHexStringStream.imbue(std::locale::classic()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we do this for a couple other stringstream objects. Could we make a derived class that automatically sets this in the ctor? Might also want to use it in getUint32PropAsOptStr
in sycl/source/detail/program_manager/program_manager.cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered making a derived class, but decided against it. The other places ( #18578 ) are few and are in both sycl and syclcompat, and just creating a class doesn't mean people will actually use it.
We've already had a "use custom iostream alternate" phase and "remove custom iostream alternate" phase in the years I've been on this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair points made. I'm hoping people will see this and be aware of it, but it bothers me that locale has an effect on stringstream
to begin with.
std::locale::global()
is a very common way for apps to initialize string localization for numeric and monetary values. Unfortunately, it is global.In this very limited fix, we are preventing it from interfering with the allowlist check which uses
std::stringstream
. The insertion of commas into numbers for the locale support messes with the expected values.We'll probably have to audit the other uses of std streams to see if they would be similarly vulnerable.