This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Clang sanitizer: remove unaligned address check #2992
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Undefined Behavior Sanitizer is causing lots of false positives around unaligned addresses, but that is expected due to our use of __unaligned modifier which the sanitizer doesn't support. So remove that check. Longer-term, we can consider special casing each method with an function attribute to ignore sanitizers for a particular method.
Examples of two such errors (there are hundreds of such errors being found during startup)
/home/steveharter/git/dotnet_coreclr/src/md/inc/metamodel.h:521:16: runtime error: load of misaligned address 0x7f2071eaba66 for type 'UINT32' (aka 'unsigned int'), which requires 4 byte alignment
#0 0x7f207990e5f5 in CMiniMdBase::getI4(void const_, CMiniColDef&) /home/steveharter/git/dotnet_coreclr/src/md/inc/metamodel.h:521:16
#1 0x7f207a376729 in CMiniMdTemplate::getPublicKeyOfAssembly(AssemblyRec_, unsigned char const**, unsigned int*) /home/steveharter/git/dotnet_coreclr/src/md/inc/metamodel.h:1881:5
#2 0x7f207a374a2f in MDInternalRO::GetAssemblyProps(unsigned int, void const**, unsigned int_, unsigned int_, char const**, AssemblyMetaDataInternal_, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/md/runtime/mdinternalro.cpp:2996:9
#3 0x7f207b091664 in BINDER_SPACE::AssemblyName::Init(IMDInternalImport_, tagPEKIND, unsigned int, int) /home/steveharter/git/dotnet_coreclr/src/binder/assemblyname.cpp:73:13
#4 0x7f207b0985e6 in BINDER_SPACE::Assembly::Init(IMDInternalImport, tagPEKIND, PEImage, PEImage_, SString&, int, int) /home/steveharter/git/dotnet_coreclr/src/binder/assembly.cpp:171:9
#5 0x7f207b0e4cb7 in BINDER_SPACE::AssemblyBinder::GetAssembly(SString&, int, int, int, BINDER_SPACE::Assembly**, char16_t const_) /home/steveharter/git/dotnet_coreclr/src/binder/assemblybinder.cpp:1690:9
#6 0x7f207b0e43b9 in BINDER_SPACE::AssemblyBinder::BindToSystem(SString&, BINDER_SPACE::Assembly__, bool) /home/steveharter/git/dotnet_coreclr/src/binder/assemblybinder.cpp:710:13
#7 0x7f207b0b123a in CCoreCLRBinderHelper::BindToSystem(ICLRPrivAssembly__, bool) /home/steveharter/git/dotnet_coreclr/src/binder/coreclrbindercommon.cpp:112:14
#8 0x7f2079497665 in PEAssembly::DoOpenSystem(IUnknown_) /home/steveharter/git/dotnet_coreclr/src/vm/pefile.cpp:3479:17
#9 0x7f2079496c21 in PEAssembly::OpenSystem(IUnknown_) /home/steveharter/git/dotnet_coreclr/src/vm/pefile.cpp:3368:18
#10 0x7f2079a780dc in SystemDomain::LoadBaseSystemClasses() /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:2826:25
#11 0x7f2079a7774c in SystemDomain::Init() /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:2562:5
#12 0x7f207964fd54 in EEStartupHelper(tagCOINITEE) /home/steveharter/git/dotnet_coreclr/src/vm/ceemain.cpp:1266:9
#13 0x7f207964d853 in EEStartup(tagCOINITEE) /home/steveharter/git/dotnet_coreclr/src/vm/ceemain.cpp:1453:5
#14 0x7f207964d31f in EnsureEEStarted(tagCOINITEE) /home/steveharter/git/dotnet_coreclr/src/vm/ceemain.cpp:429:17
#15 0x7f207928140e in CorHost2::Start() /home/steveharter/git/dotnet_coreclr/src/vm/corhost.cpp:846:14
#16 0x7f207920fc4a in coreclr_initialize /home/steveharter/git/dotnet_coreclr/src/dlls/mscoree/unixinterface.cpp:228:10
#17 0x4eb427 in ExecuteManagedAssembly(char const_, char const_, char const_, int, char const**) /home/steveharter/git/dotnet_coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp:357:22
#18 0x4e9988 in corerun(int, char const**) /home/steveharter/git/dotnet_coreclr/src/coreclr/hosts/unixcorerun/corerun.cpp:149:20
#19 0x7f207faf1ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287
#20 0x43c1e6 in _start (/home/steveharter/netcore/corerun+0x43c1e6)
and
SUMMARY: AddressSanitizer: undefined-behavior /home/steveharter/git/dotnet_coreclr/src/jit/emit.h:607
/home/steveharter/git/dotnet_coreclr/src/jit/emit.cpp:851:13: runtime error: member access within misaligned address 0x63100002d374 for type 'emitter::instrDescJmp', which requires 8 byte alignment
#0 0x7f207aaaa2ed in emitter::emitSavIG(bool) /home/steveharter/git/dotnet_coreclr/src/jit/emit.cpp:851:13
#1 0x7f207aaaf66a in emitter::emitNxtIG(bool) /home/steveharter/git/dotnet_coreclr/src/jit/emit.cpp:6421:5
#2 0x7f207aab7dd3 in emitter::emitAddLabel(unsigned long_, unsigned int, unsigned int, int) /home/steveharter/git/dotnet_coreclr/src/jit/emit.cpp:2447:9
#3 0x7f207aca00a7 in CodeGen::genCodeForBBlist() /home/steveharter/git/dotnet_coreclr/src/jit/codegenxarch.cpp:515:35
#4 0x7f207ab97230 in CodeGen::genGenerateCode(void__, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/jit/codegencommon.cpp:2920:5
#5 0x7f207ad69a8e in Compiler::compCompile(void**, unsigned int_, unsigned int) /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:3986:5
#6 0x7f207ad79cdd in Compiler::compCompileHelper(CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, CorInfoInstantiationVerification) /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:5017:9
#7 0x7f207ad7271c in Compiler::compCompile(CORINFO_METHOD_STRUCT__, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void__, unsigned int_, unsigned int)::$1::operator()(Compiler::compCompile(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int)::JITParam) const /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:4396:26
#8 0x7f207ad6f755 in Compiler::compCompile(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int) /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:4418:5
#9 0x7f207adad5d0 in jitNativeCode(CORINFO_METHOD_STRUCT__, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void__, unsigned int_, unsigned int, void_)::$3::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void__, unsigned int_, unsigned int, void_)::JITParam) const::{lambda(jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::$3::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::JITParam) const::JITParam)#1}::operator()(jitNativeCode(CORINFO_METHOD_STRUCT, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::$3::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::JITParam) const::JITParam) const /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:5632:30
#10 0x7f207ad8e38f in jitNativeCode(CORINFO_METHOD_STRUCT, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::$3::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void**, unsigned int_, unsigned int, void_)::JITParam) const /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:5668:9
#11 0x7f207ad8dafa in jitNativeCode(CORINFO_METHOD_STRUCT_, CORINFO_MODULE_STRUCT__, ICorJitInfo_, CORINFO_METHOD_INFO_, void__, unsigned int_, unsigned int, void_) /home/steveharter/git/dotnet_coreclr/src/jit/compiler.cpp:5670:5
#12 0x7f207a56b368 in CILJit::compileMethod(ICorJitInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned char__, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/jit/ee_il_dll.cpp:176:14
#13 0x7f20793a7844 in invokeCompileMethodHelper(EEJitManager_, CEEInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned int, unsigned char__, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/vm/jitinterface.cpp:12059:15
#14 0x7f20793a9179 in invokeCompileMethod(EEJitManager_, CEEInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned int, unsigned char__, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/vm/jitinterface.cpp:12112:24
#15 0x7f20793a99b3 in CallCompileMethodWithSEHWrapper(EEJitManager_, CEEInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned int, unsigned char__, unsigned int_, MethodDesc_)::$2::operator()(CallCompileMethodWithSEHWrapper(EEJitManager, CEEInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned int, unsigned char**, unsigned int_, MethodDesc_)::Param_) const /home/steveharter/git/dotnet_coreclr/src/vm/jitinterface.cpp:12174:23
#16 0x7f20793a961a in CallCompileMethodWithSEHWrapper(EEJitManager_, CEEInfo_, CORINFO_METHOD_INFO_, unsigned int, unsigned int, unsigned char**, unsigned int_, MethodDesc_) /home/steveharter/git/dotnet_coreclr/src/vm/jitinterface.cpp:12217:5
#17 0x7f20793ad297 in UnsafeJitFunction(MethodDesc_, COR_ILMETHOD_DECODER_, unsigned int, unsigned int, unsigned int_) /home/steveharter/git/dotnet_coreclr/src/vm/jitinterface.cpp:12871:19
#18 0x7f2079f80eb2 in MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER_, unsigned int, unsigned int) /home/steveharter/git/dotnet_coreclr/src/vm/prestub.cpp:461:25
#19 0x7f2079f863fc in MethodDesc::DoPrestub(MethodTable_) /home/steveharter/git/dotnet_coreclr/src/vm/prestub.cpp:1449:21
#20 0x7f2079f84864 in PreStubWorker /home/steveharter/git/dotnet_coreclr/src/vm/prestub.cpp:1036:16
#21 0x7f2079a6339b in ThePreStub /home/steveharter/git/dotnet_coreclr/bin/obj/Linux.x64.Debug/src/vm/wks/theprestubamd64.S:796
#22 0x7f2079a62a1a in CallDescrWorkerInternal /home/steveharter/git/dotnet_coreclr/bin/obj/Linux.x64.Debug/src/vm/wks/calldescrworkeramd64.S:860
#23 0x7f2079649fdd in CallDescrWorkerWithHandler(CallDescrData_, int) /home/steveharter/git/dotnet_coreclr/src/vm/callhelpers.cpp:87:5
#24 0x7f207964bfb1 in MethodDescCallSite::CallTargetWorker(unsigned long const_) /home/steveharter/git/dotnet_coreclr/src/vm/callhelpers.cpp:632:9
#25 0x7f2079a807b7 in AppDomain::InitializeDomainContext(int, char16_t const_, char16_t const_) /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:9946:9
#26 0x7f2079a7f263 in SystemDomain::InitializeDefaultDomain(int, ICLRPrivBinder_) /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:3504:9
#27 0x7f2079a7dfd2 in SystemDomain::SetupDefaultDomain() /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:3375:13
#28 0x7f2079a7f8fd in SystemDomain::SetupDefaultDomainNoThrow() /home/steveharter/git/dotnet_coreclr/src/vm/appdomain.cpp:3398:9
#29 0x7f207964d8e2 in EEStartup(tagCOINITEE) /home/steveharter/git/dotnet_coreclr/src/vm/ceemain.cpp:1462:29
#30 0x7f207964d31f in EnsureEEStarted(tagCOINITEE) /home/steveharter/git/dotnet_coreclr/src/vm/ceemain.cpp:429:17
#31 0x7f207928140e in CorHost2::Start() /home/steveharter/git/dotnet_coreclr/src/vm/corhost.cpp:846:14
#32 0x7f207920fc4a in coreclr_initialize /home/steveharter/git/dotnet_coreclr/src/dlls/mscoree/unixinterface.cpp:228:10
#33 0x4eb427 in ExecuteManagedAssembly(char const_, char const_, char const_, int, char const__) /home/steveharter/git/dotnet_coreclr/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp:357:22
#34 0x4e9988 in corerun(int, char const_*) /home/steveharter/git/dotnet_coreclr/src/coreclr/hosts/unixcorerun/corerun.cpp:149:20
#35 0x7f207faf1ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287
#36 0x43c1e6 in _start (/home/steveharter/netcore/corerun+0x43c1e6)