llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.83k stars 11.46k forks source link

Clang crash: hotpatch combined with __asm__ function #72981

Open a-mitm opened 9 months ago

a-mitm commented 9 months ago

clang on the following code crashes with flag "-fms-hotpatch"

inline void __disable(void){
    __asm__ volatile ("cli");
}

int main(){
    __disable();
}

command line : "C:\Program Files\LLVM\bin\clang-cl.exe" -fms-hotpatch -Oz tmp.cpp

1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'tmp.cpp'.
4.      Running pass 'X86 Assembly Printer' on function '@"?__disable@@YAXXZ"'
Exception Code: 0x80000003
 #0 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x104dfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x104b131
 #1 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x10484e6 C:\Program Files\LLVM\bin\clang-cl.exe 0x657d28
 #2 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x240604 C:\Program Files\LLVM\bin\clang-cl.exe 0x6d825d
 #3 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x3824c8 C:\Program Files\LLVM\bin\clang-cl.exe 0x3885d3
 #4 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x382b57 C:\Program Files\LLVM\bin\clang-cl.exe 0x14cc4d4
 #5 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x189841e C:\Program Files\LLVM\bin\clang-cl.exe 0x314e644
 #6 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x1802352 C:\Program Files\LLVM\bin\clang-cl.exe 0x5bd4ed
 #7 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x64fdfe C:\Program Files\LLVM\bin\clang-cl.exe 0x8bd6
 #8 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x53a9 C:\Program Files\LLVM\bin\clang-cl.exe 0x3c90
 #9 0x00007ff68eefdfcf C:\Program Files\LLVM\bin\clang-cl.exe 0x16f14 C:\Program Files\LLVM\bin\clang-cl.exe 0x45a0df0
#10 0x00007ff68eefdfcf (C:\Program Files\LLVM\bin\clang-cl.exe+0x104dfcf)
#11 0x00007ff68eefb131 (C:\Program Files\LLVM\bin\clang-cl.exe+0x104b131)
0x00007FF68EEFDFCF, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x104DFCF byte(s)
0x00007FF68EEFB131, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x104B131 byte(s)
0x00007FF68EEF84E6, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x10484E6 byte(s)
0x00007FF68E507D28, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x657D28 byte(s)
0x00007FF68E0F0604, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x240604 byte(s)
0x00007FF68E58825D, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x6D825D byte(s)
0x00007FF68E2324C8, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x3824C8 byte(s)
0x00007FF68E2385D3, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x3885D3 byte(s)
0x00007FF68E232B57, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x382B57 byte(s)
0x00007FF68F37C4D4, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x14CC4D4 byte(s)
0x00007FF68F74841E, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x189841E byte(s)
0x00007FF690FFE644, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x314E644 byte(s)
0x00007FF68F6B2352, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x1802352 byte(s)
0x00007FF68E46D4ED, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x5BD4ED byte(s)
0x00007FF68E4FFDFE, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x64FDFE byte(s)
0x00007FF68DEB8BD6, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x8BD6 byte(s)
0x00007FF68DEB53A9, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x53A9 byte(s)
0x00007FF68DEB3C90, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x3C90 byte(s)
0x00007FF68DEC6F14, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x16F14 byte(s)
0x00007FF692450DF0, C:\Program Files\LLVM\bin\clang-cl.exe(0x00007FF68DEB0000) + 0x45A0DF0 byte(s)
0x00007FFB9AD3257D, C:\WINDOWS\System32\KERNEL32.DLL(0x00007FFB9AD20000) + 0x1257D byte(s), BaseThreadInitThunk() + 0x1D byte(s)
0x00007FFB9BDEAA58, C:\WINDOWS\SYSTEM32\ntdll.dll(0x00007FFB9BD90000) + 0x5AA58 byte(s), RtlUserThreadStart() + 0x28 byte(s)
clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.4
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
clang-cl: note: diagnostic msg:
********************

crash.zip

knightXun commented 9 months ago

mark!