| Issue |
233544
|
| Summary |
[ASan][Windows][MSVC ABI] Crash on typeid() or what() of caught std::exception reference
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
peterkochlarsen
|
When cross-compiling for Windows on ubuntu, I get weird runtime errors when using -fsanitize=address, in both 32-bit and 64-bit mode.
This minimal program reproduces it:
#include <stdexcept>
#include <typeinfo>
int main()
{
try
{
throw std::runtime_error("hello");
}
catch (const std::exception& e)
{
auto volatile p = typeid(e).name();
}
}
Generates the following ASAN-exception in 32-bit mode:
./clangw_debug/asan.exe
=================================================================
==37872==ERROR: AddressSanitizer: access-violation on unknown address 0x49ffae97 (pc 0x00d511cc bp 0x00cffde4 sp 0x00cff424 T0)
==37872==The signal is caused by a READ memory access.
#0 0x00d511cb in main d:\git\bes_devel\udf\sw\udf_core\asan\asan.cpp:11
#1 0x00d546a2 in __scrt_file_policy::set_commode+0x52 (D:\git\bes_devel\udf\sw\udf_core\asan\clangw_debug\asan.exe+0x4046a2)
#2 0x00d54809 in __scrt_file_policy::set_commode+0x1b9 (D:\git\bes_devel\udf\sw\udf_core\asan\clangw_debug\asan.exe+0x404809)
#3 0x00d548dc in __scrt_file_policy::set_commode+0x28c (D:\git\bes_devel\udf\sw\udf_core\asan\clangw_debug\asan.exe+0x4048dc)
#4 0x00d548e7 in mainCRTStartup+0x7 (D:\git\bes_devel\udf\sw\udf_core\asan\clangw_debug\asan.exe+0x4048e7)
#5 0x76425d48 in BaseThreadInitThunk+0x18 (C:\WINDOWS\System32\KERNEL32.DLL+0x10015d48)
#6 0x773de1fa in RtlInitializeExceptionChain+0x6a (C:\WINDOWS\SYSTEM32\ntdll.dll+0x4b2ee1fa)
#7 0x773de180 in RtlGetAppContainerNamedObjectPath+0x230 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x4b2ee180)
==37872==Register values:
eax = cffd74b9 ebx = 0 ecx = cffd67 edx = 19ffae97
edi = 0 esi = cffd60 ebp = cffde4 esp = cff424
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation d:\git\bes_devel\udf\sw\udf_core\asan\asan.cpp:11 in main
==37872==ABORTING
Output from the compilation/linking step is:
make -j20 -f asan.mk VERBOSE=4
Give me fuel, give me fire...
Building: udf/sw/udf_core/asan/asan.mk: clangwdebug_mntdgitbesdeveludfswudfcoreasanasanmk
* ccache is not enabled
* ICECC is not enabled
* clang 20.1.2 (ASAN enabled)
mkdir -p clangw_debug
mkdir -p /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug
set -o pipefail && echo clangw_debug '> clw32' asan.cpp &&
clang++-20 -std=c++17 -fsanitize=address -fno-omit-frame-pointer -O1
-fms-runtime-lib=static_dbg
-target i686-pc-windows-msvc -fdiagnostics-color=always -fdiagnostics-absolute-paths
-isystem /usr/lib/llvm-20/lib/clang/20/include
-isystem /opt/cross-vs/17//VC/Tools/MSVC/14.44.35207/include
-isystem /opt/cross-vs/17//Windows\ Kits/10/Include/10.0.26100.0/ucrt
-isystem /opt/cross-vs/17//Windows\ Kits/10/Include/10.0.26100.0/shared
-isystem /opt/cross-vs/17//Windows\ Kits/10/Include/10.0.26100.0/um
-isystem /opt/cross-vs/17//Windows\ Kits/10/Include/10.0.26100.0/winrt
-isystem /opt/cross-vs/17//Windows\ Kits/10/Include/10.0.26100.0/cppwinrt
-fdebug-prefix-map=/mnt/d/=d:/
-fmacro-prefix-map=/mnt/d/git/bes_devel/=
-gdwarf -gcodeview
-I/mnt/d/git/bes_devel/udf/sw/udf_core/asan
-I/mnt/d/git/bes_devel/build-mk2
-I/mnt/d/git/bes_devel
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
-DCPU_X86 -DWIN32_LEAN_AND_MEAN -DUSEPACKAGES -D_RTLDLL
-Wall -Wextra -Wno-zero-as-null-pointer-constant -Wno-global-constructors
-Wno-suggest-override -Wno-trigraphs -Wno-ignored-qualifiers
-o /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.obj
-c /mnt/d/git/bes_devel/udf/sw/udf_core/asan/asan.cpp -MMD
-MT /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.obj
-MF /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.P 2> >(sed -E 's/(ICECC.*)(Error: )/\1/g') | cat
clangw_debug > clw32 asan.cpp
echo Making: /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe:
&& set -o pipefail && export VCToolsInstallDir=/opt/cross-vs/17/
&& clang++-20 -target i686-pc-windows-msvc -debug -fms-runtime-lib=static_dbg
-fno-lto -fuse-ld=lld-link-20 -o /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe
./clangw_debug/asan.obj
-L/opt/cross-vs/17//VC/Tools/MSVC/14.44.35207/lib/x86
-L/opt/cross-vs/17//Windows\ Kits/10/Lib/10.0.26100.0/ucrt/x86
-L/opt/cross-vs/17//Windows\ Kits/10/Lib/10.0.26100.0/um/x86
-Xlinker /subsystem:console
-Xlinker /safeseh:no
-Xlinker /ignore:longsections
-Xlinker /DEBUG:FULL -Xlinker --color-diagnostics
-Xlinker /pdbsourcepath:d:/opt/cross-vs/17/
-Xlinker /IGNORE:4099 -lclang_rt.asan_dynamic-i386.lib
-lclang_rt.asan_static_runtime_thunk-i386.lib
-Xlinker /wholearchive:clang_rt.asan_static_runtime_thunk-i386.lib
-lshlwapi -luser32 -lole32.lib -lwinmm -ladvapi32 -ldbghelp -v
&& strip /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe
&& cp -f "/opt/cross-vs/17//VC/Tools/MSVC/14.44.35207/bin/Hostx64/x86/clang_rt.asan_dynamic-i386.dll" "/mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/" && :
&& echo /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe - Complete | sponge
Making: /mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe:
Ubuntu clang version 20.1.2 (0ubuntu1~24.04.3)
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
"/usr/bin/lld-link-20" -out:/mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe -defaultlib:libcmt -defaultlib:oldnames -libpath:/opt/cross-vs/17/lib/x86 -libpath:/opt/cross-vs/17/atlmfc/lib/x86 -libpath:/opt/cross-vs/17//VC/Tools/MSVC/14.44.35207/lib/x86 "-libpath:/opt/cross-vs/17//Windows Kits/10/Lib/10.0.26100.0/ucrt/x86" "-libpath:/opt/cross-vs/17//Windows Kits/10/Lib/10.0.26100.0/um/x86" -nologo ./clangw_debug/asan.obj /subsystem:console /safeseh:no /ignore:longsections /DEBUG:FULL --color-diagnostics /pdbsourcepath:d:/opt/cross-vs/17/ /IGNORE:4099 clang_rt.asan_dynamic-i386.lib clang_rt.asan_static_runtime_thunk-i386.lib /wholearchive:clang_rt.asan_static_runtime_thunk-i386.lib shlwapi.lib user32.lib ole32.lib winmm.lib advapi32.lib dbghelp.lib
/mnt/d/git/bes_devel/udf/sw/udf_core/asan/clangw_debug/asan.exe - Complete
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs