[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

Russell Gallop via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 09:46:49 PST 2021


russell.gallop added a comment.

I've focussed on the test test-global-init-nonzero-sm-pic.ll which fails writing to an address which (I believe) should be in the .data section but isn't.

With some breakpoints in SectionMemoryManager.cpp it appears that this fails when the top 32bits of the .text allocated address and the .data allocated address are different:

  Allocating Data section ".data"
  Returning aligned address 0x000001ed 30f60000 of size 0x0000000000000004
  Allocating code section ".text"
  Returning aligned address 0x0000022d 31050000 of size 0x000000000000003a

And work when they happen to be the same. When this fails, the address causing the access violation is the top 32bits of the .text address and the bottom 32bits of the .data address, e.g. 0x0000022d 30f60000. This doesn't fail without scudo as the top 32bits of the addresses seem to always be the same.

With assertions enabled this is causing an assert:

  f:\git\llvm-project\stage1_scudo>"f:\git\llvm-project\stage1_scudo\bin\lli.exe" "-mtriple=x86_64-pc-windows-msvc-elf" "-relocation-model=pic" "-code-model=small" "f:\git\llvm-project\llvm\test\ExecutionEngine\MCJIT\test-global-init-nonzero-sm-pic.ll"
  Assertion failed: isInt<32>(RealOffset), file F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldELF.cpp, line 300
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
  Stack dump:
  0.      Program arguments: f:\\git\\llvm-project\\stage1_scudo\\bin\\lli.exe -mtriple=x86_64-pc-windows-msvc-elf -relocation-model=pic -code-model=small f:\\git\\llvm-project\\llvm\\test\\ExecutionEngine\\MCJIT\\test-global-init-nonzero-sm-pic.ll
   #0 0x00007ff63eb423c5 HandleAbort F:\git\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
   #1 0x00007ff63f89d951 raise minkernel\crts\ucrt\src\appcrt\misc\signal.cpp:547:0
   #2 0x00007ff63f8617cc abort minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:71:0
   #3 0x00007ff63f8825b8 common_assert_to_stderr<wchar_t> minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:175:0
   #4 0x00007ff63f882d42 _wassert minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:443:0
   #5 0x00007ff63e749e96 llvm::RuntimeDyldELF::resolveX86_64Relocation(class llvm::SectionEntry const &, unsigned __int64, unsigned __int64, unsigned int, __int64, unsigned __int64) F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldELF.cpp:302:0
   #6 0x00007ff63e7496be llvm::RuntimeDyldELF::resolveRelocation(class llvm::RelocationEntry const &, unsigned __int64) F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldELF.cpp:932:0
   #7 0x00007ff63e72e656 llvm::RuntimeDyldImpl::resolveRelocationList(class llvm::SmallVector<class llvm::RelocationEntry, 64> const &, unsigned __int64) F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:1077:0
   #8 0x00007ff63e72e52c ::operator++ C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\include\list:166:0
   #9 0x00007ff63e72e52c ::operator++ C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\include\list:247:0
  #10 0x00007ff63e72e52c llvm::RuntimeDyldImpl::resolveLocalRelocations(void) F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:145:0
  #11 0x00007ff63e72e872 llvm::RuntimeDyldImpl::resolveRelocations(void) F:\git\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:139:0
  #12 0x00007ff63e532601 llvm::MCJIT::finalizeLoadedModules(void) F:\git\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:245:0
  #13 0x00007ff63e532bfd ::{dtor} F:\git\llvm-project\llvm\include\llvm\ADT\SmallVector.h:1045:0
  #14 0x00007ff63e532bfd llvm::MCJIT::finalizeObject(void) F:\git\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:271:0
  #15 0x00007ff63dcfa06c main F:\git\llvm-project\llvm\tools\lli\lli.cpp:633:0
  #16 0x00007ff63f81527c invoke_main d:\agent\_work\63\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
  #17 0x00007ff63f81527c __scrt_common_main_seh d:\agent\_work\63\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
  #18 0x00007ffd145a7034 (C:\WINDOWS\System32\KERNEL32.DLL+0x17034)
  #19 0x00007ffd1657d0d1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x4d0d1)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86694/new/

https://reviews.llvm.org/D86694



More information about the cfe-commits mailing list