Stop false positive in clang array OOB sanitiser - #1395
Conversation
|
This looks good, I think I also saw some compiler warnings about this |
|
Though, it makes getting a pointer to a single row more awkward. Maybe we can have a helper function for that. |
|
Another thought I did have was to add an extra item to the union instead of changing |
|
That seems clean, but I think in c++ it might be undefined behaviour to alias using a union. Maybe it's something that could be done using a simple wrapper class. |
|
Accessing anything other than the "active" entry (last written to) is UB per the spec, but the big three compilers all define it as allowed assuming you're compiling with any strict aliasing stuff disabled (hxcpp does). |
Where does hxcpp disable strict aliasing? The only target that has |
|
Hmm, I could have sworn it was disabled for everything. I'm going to continue using reinterpret_cast over memcpy or whatever madness is the "correct" way, there's plenty of code in hxcpp which does type punning and so I don't think it's a concern. |
|
|
yeah, char and std::byte are special in regards to aliasing. But there's plenty of reinterpreting of unrelated (but byte wise compatible) types, all of the stuff related to socket_in6 in Socket.cpp comes to mind, same with everything related to wchar_t and char16_t on Windows. |
When the GC runs with all of clangs sanitisers enabled you get lots of false positive errors about OOB array access on
mRow. This is because a lot of code accesses the 0th entry of the first array to basically treat it as a single chunk of memory, this does work fine as 2D arrays are just a big chunk of memory.Clangs sanitisers are tripped up by this though, so I've changed
mRowto actually be one big array since there was more access to it as a 1D array than a 2D array. This should make it easier to not lose track of actually important sanitisation errors.