Open arthurbiancarelli opened 3 years ago
Thanks, @arthurbiancarelli - this is probably as good a place as any.
Given that this works with MSVC on ARM64 (per the report) and Clang targeting both x86 and x64 (I verified), I suspect the root cause is an issue with Clang's implementation of the MS ABI on ARM64. We'll need to reduce this repro and make it library-free to prove that's the case, at which time we can report the bug to our Clang friends and (hopefully) devise a workaround.
I tried to reduce the example a bit, did not succeed without the library though:
#include <xlocale>
struct ctype : std::ctype<unsigned char> {
};
int main() {
ctype type; // Crash on destruction; access violation when freeing _Ctype._LocaleName
return 0;
}
I think you're right that it is an ABI issue or related because I just found out the original example (or this one) does not crash when I link to the static version of the C++ runtime
Describe the bug Instantiating a derived class from
basic_ostream
usingunsigned char
as the character type results in a access violation when compiling with Clang. Crash occurs in theinit
method ofstd::basic_ios
when accessing the ctype of thestd::_Locinfo
class (init
callswiden
thenuse_facet
, etc...)Command-line test case
Expected behavior This code should not crash
STL version
Additional context Hope this is the good place to report this, that this code is valid and that I'm using the correct compile options for ClangCl. Please note that this crash does not occur with MSVC compiler. I'm cross-compiling this code on a x64 Host and deploying it on a fresh Windows installation (Windows 10 Professional, Build 21364.1 emulated on a mac M1 hardware) using the Visual Studio remote debugger.