You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C:\Temp>cl /clr /nologo /W4 /std:c++20 /MDd /Od D:\msvc\src\vctools\crt\github\tests\std\tests\VSO_0000000_vector_algorithms\test.cpp /I D:\msvc\src\vctools\crt\github\tests\std\include
test.cpp
C:\Temp>test
This is a randomized test.
DO NOT IGNORE/RERUN ANY FAILURES.
You must report them to the STL maintainers.
Seed vector: [...]
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at __std_find_trivial_unsized_8(Void* , UInt64 )
at std.ranges._Find_unchecked<unsigned __int64 *,struct std::unreachable_sentinel_t,unsigned __int64,struct std::identity>(UInt64* _First, unreachable_sentinel_t _Last, UInt64* _Val, identity _Proj)
at std.ranges._Find_fn.operator()<unsigned __int64 *,struct std::unreachable_sentinel_t,unsigned __int64,struct std::identity>(_Find_fn* , UInt64* _First, unreachable_sentinel_t _Last, UInt64* _Val, identity _Proj)
at test_gh_4449<unsigned __int64>()
at test_vector_algorithms(mersenne_twister_engine<unsigned __int64\,64\,312\,156\,31\,-5403634167711393303\,29\,6148914691236517205\,17\,8202884508482404352\,37\,-2270628950310912\,43\,6364136223846793005>* gen)
at main()
at _mainCRTStartup()
I can also repro this with plain VS 2022 17.10 Preview 1 x86, if I take #4450's test and alter it to disable the assert(where == arr + mid2), so this doesn't appear to be a regression caused by #4450.
The text was updated successfully, but these errors were encountered:
@AlexGuteniev realized that this isn't /clr-specific! Vectorized find-unsized assumes that its N-byte elements are N-aligned, but x86 notoriously only has a 4-aligned stack even for 8-byte elements. When this happens, we'll generally run off the end - unrelated to the before-begin masking.
#pragma pack repros this quite nicely. I believe I can fix this by adding an alignment check to the algorithm.
StephanTLavavej
changed the title
vector_algorithms.cpp: x86 /clr System.AccessViolationException at __std_find_trivial_unsized_8vector_algorithms.cpp: __std_find_trivial_unsized_impl assumes N-byte elements are N-aligned
Mar 6, 2024
This initially appeared to be x86
/clr
specific - but it wasn't, see below.With #4450 and an MSVC-internal build:
I can also repro this with plain VS 2022 17.10 Preview 1 x86, if I take #4450's test and alter it to disable the
assert(where == arr + mid2)
, so this doesn't appear to be a regression caused by #4450.The text was updated successfully, but these errors were encountered: