Chris Tetreault via llvm-dev
2021-Mar-09 20:22 UTC
[llvm-dev] Help: Windows: lli crashes on 32 arch but not on 64 arch
You should be able to directly debug in visual studio. Build and run lli with your hw-m32.ll added to the debug args. Make sure you do a debug build. The assert should cause the visual studio debugger to break and you can examine the call stack and figure out relevant breakpoints to set. From: llvm-dev <llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>> On Behalf Of Francis ANDRE via llvm-dev Sent: Tuesday, March 9, 2021 10:34 AM To: LLVM Developers' List <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> Subject: [EXT] [llvm-dev] Help: Windows: lli crashes on 32 arch but not on 64 arch Hello LLVM list I am running with lli, a simple HelloWorld program twice, once targeted to 32 bits arch, the other targeted to 64 bit arch. While it is working fine with the 64 arch, it craches with the 32 arch. Below are the steps clang.cmd -v -g -m64 -emit-llvm -S hw.c -o hw-m64.ll clang.cmd -v -g -m32 -emit-llvm -S hw.c -o hw-m32.ll C:\Program Files (x86)\LLVM\11.0\bin"\clang -v -g -m32 -emit-llvm -S e.c -o e-m32.ll clang version 11.0.0 Target: i686-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files (x86)\LLVM\11.0\bin (in-process) "C:\\Program Files (x86)\\LLVM\\11.0\\bin\\clang.exe<file://LLVM/11.0/bin/clang.exe>" -cc1 -triple i686-pc-windows-msvc19.28.29335 -emit-llvm -disable-free -disable-llvm-verifier -discard-value-names -main-file-name e.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu pentium4 -gno-column-info -gcodeview -debug-info-kind=limited -v -resource-dir "C:\\Program Files (x86)\\LLVM\\11.0\\lib\\clang\\11.0.0<file://LLVM/11.0/lib/clang/11.0.0>" -internal-isystem "C:\\Program Files (x86)\\LLVM\\11.0\\lib\\clang\\11.0.0\\include<file://LLVM/11.0/lib/clang/11.0.0/include>" -internal-isystem "C:\\Program Files (x86)\\Microsoft<file://Microsoft> Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft<file://Microsoft> Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows<file://Windows> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows<file://Windows> Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows<file://Windows> Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows<file://Windows> Kits\\10\\include\\10.0.18362.0\\winrt" -fdebug-compilation-dir "D:\\projects\\as400\\rpg\\clang" -ferror-limit 19 -fmessage-length=194 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.28.29335 -fdelayed-template-parsing -fcolor-diagnostics -faddrsig -o e-m32.ll -x c e.c clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target i686-pc-windows-msvc #include "..." search starts here: #include <...> search starts here: C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0\include C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt End of search list. lli hw-m64.ll Hello World! lli hw-m32.ll PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: D:\\llvm-project\\build32\\Debug\\bin\\lli hw-m32.ll #0 0x04b8eacc #1 0x03ff017b #2 0x03ff032b #3 0x0153ca18 llvm::MCJIT::runFunction(class llvm::Function *, class llvm::ArrayRef<struct llvm::GenericValue>) D:\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:587:0 #4 0x01459673 llvm::ExecutionEngine::runFunctionAsMain(class llvm::Function *, class std::vector<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>, class std::allocator<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>>> const &, char const *const *) D:\llvm-project\llvm\lib\ExecutionEngine\ExecutionEngine.cpp:467:0 #5 0x007e08c5 main D:\llvm-project\llvm\tools\lli\lli.cpp:643:0 #6 0x02e12013 invoke_main d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0 #7 0x02e11e97 _scrt_common_main_seh d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0 #8 0x02e11d2d _scrt_common_main d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0 #9 0x02e12098 mainCRTStartup d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0 #10 0x75336359 (C:\WINDOWS\System32\KERNEL32.DLL+0x16359) #11 0x774c8944 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68944) #12 0x774c8914 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68914) What is the best way to debug the 32 bit arch lli.exe under VS2019? D:\projects\clang>type hw.c #include <stdio.h> int main() { printf("Hello World!\n"); return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210309/44d7c1ef/attachment.html>
Francis ANDRE via llvm-dev
2021-Mar-10 13:58 UTC
[llvm-dev] *** SPAM *** Re: Help: Windows: lli crashes on 32 arch but not on 64 arch
I found something, a real difference between the log in 32 arch and the log in 64 arch by running 1. lli.exe -debug hw-m32.ll > lli-hw-m32.log 2>&1 2. lli.exe -debug hw-m64.ll > lli-hw-m64.log 2>&1 In the 32 case, there is a undefined symbol: ErrorStr "Symbol not found: ___acrt_iob_func" std::string, and in fact, the symbol '___acrt_iob_func' (with 3 '_' before) does not exist in the C:\WINDOWS\SYSTEM32\ucrtbased.dll, but there is a '__acrt_iob_func' (2 '_' before) symbol exported. The other strange thing is that in the lli-hw-m64.log, there is never a '___acrt_iob_func' but only '__acrt_iob_func' references and the lli 64 execution is working fine. And the assert below uint8_t *getAddressWithOffset(unsigned OffsetBytes) const { assert(OffsetBytes <= AllocationSize && "Offset out of bounds!"); return Address + OffsetBytes; } is failing around solving a relocation of '___acrt_iob_func' in the section 4. Thus, I am suggesting that solving the undefined issue on '___acrt_iob_func' should solve the issue The llvm::RuntimeDynldCOOF is too much complex for me to jump into. To whom, I could submit those informations for a fix? Le 09/03/2021 à 21:22, Chris Tetreault via llvm-dev a écrit :> > You should be able to directly debug in visual studio. Build and run > lli with your hw-m32.ll added to the debug args. Make sure you do a > debug build. The assert should cause the visual studio debugger to > break and you can examine the call stack and figure out relevant > breakpoints to set. > > *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org > <mailto:llvm-dev-bounces at lists.llvm.org>> *On Behalf Of *Francis ANDRE > via llvm-dev > *Sent:* Tuesday, March 9, 2021 10:34 AM > *To:* LLVM Developers' List <llvm-dev at lists.llvm.org > <mailto:llvm-dev at lists.llvm.org>> > *Subject:* [EXT] [llvm-dev] Help: Windows: lli crashes on 32 arch but > not on 64 arch > > Hello LLVM list > > I am running with lli, a simple HelloWorld program twice, once > targeted to 32 bits arch, the other targeted to 64 bit arch. While it > is working fine with the 64 arch, it craches with the 32 arch. Below > are the steps > > clang.cmd -v -g -m64 -emit-llvm -S hw.c -o hw-m64.ll > > clang.cmd -v -g -m32 -emit-llvm -S hw.c -o hw-m32.ll > > C:\Program Files (x86)\LLVM\11.0\bin"\clang -v -g -m32 -emit-llvm > -S e.c -o e-m32.ll > clang version 11.0.0 > Target: i686-pc-windows-msvc > Thread model: posix > InstalledDir: C:\Program Files (x86)\LLVM\11.0\bin > (in-process) > "C:\\Program Files (x86)\\LLVM\\11.0\\bin\\clang.exe > <file://LLVM/11.0/bin/clang.exe>" -cc1 -triple > i686-pc-windows-msvc19.28.29335 -emit-llvm -disable-free > -disable-llvm-verifier -discard-value-names -main-file-name e.c > -mrelocation-model static -mframe-pointer=all -fmath-errno > -fno-rounding-math -mconstructor-aliases -target-cpu pentium4 > -gno-column-info -gcodeview -debug-info-kind=limited -v > -resource-dir "C:\\Program Files > (x86)\\LLVM\\11.0\\lib\\clang\\11.0.0 > <file://LLVM/11.0/lib/clang/11.0.0>" -internal-isystem > "C:\\Program Files (x86)\\LLVM\\11.0\\lib\\clang\\11.0.0\\include > <file://LLVM/11.0/lib/clang/11.0.0/include>" -internal-isystem > "C:\\Program Files (x86)\\Microsoft <file://Microsoft> Visual > Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\include" > -internal-isystem "C:\\Program Files (x86)\\Microsoft > <file://Microsoft> Visual > Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\atlmfc\\include" > -internal-isystem "C:\\Program Files (x86)\\Windows > <file://Windows> Kits\\10\\Include\\10.0.18362.0\\ucrt" > -internal-isystem "C:\\Program Files (x86)\\Windows > <file://Windows> Kits\\10\\include\\10.0.18362.0\\shared" > -internal-isystem "C:\\Program Files (x86)\\Windows > <file://Windows> Kits\\10\\include\\10.0.18362.0\\um" > -internal-isystem "C:\\Program Files (x86)\\Windows > <file://Windows> Kits\\10\\include\\10.0.18362.0\\winrt" > -fdebug-compilation-dir "D:\\projects\\as400\\rpg\\clang" > -ferror-limit 19 -fmessage-length=194 -fno-use-cxa-atexit > -fms-extensions -fms-compatibility > -fms-compatibility-version=19.28.29335 -fdelayed-template-parsing > -fcolor-diagnostics -faddrsig -o e-m32.ll -x c e.c > clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target > i686-pc-windows-msvc > #include "..." search starts here: > #include <...> search starts here: > C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0\include > C:\Program Files (x86)\Microsoft Visual > Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include > C:\Program Files (x86)\Microsoft Visual > Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include > C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt > C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared > C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um > C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt > End of search list. > > lli hw-m64.ll > > Hello World! > > lli hw-m32.ll > > PLEASE submit a bug report to https://bugs.llvm.org/ > <https://bugs.llvm.org/> and include the crash backtrace. > Stack dump: > 0. Program arguments: > D:\\llvm-project\\build32\\Debug\\bin\\lli hw-m32.ll > #0 0x04b8eacc > #1 0x03ff017b > #2 0x03ff032b > #3 0x0153ca18 llvm::MCJIT::runFunction(class llvm::Function *, > class llvm::ArrayRef<struct llvm::GenericValue>) > D:\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:587:0 > #4 0x01459673 llvm::ExecutionEngine::runFunctionAsMain(class > llvm::Function *, class std::vector<class std::basic_string<char, > struct std::char_traits<char>, class std::allocator<char>>, class > std::allocator<class std::basic_string<char, struct > std::char_traits<char>, class std::allocator<char>>>> const &, > char const *const *) > D:\llvm-project\llvm\lib\ExecutionEngine\ExecutionEngine.cpp:467:0 > #5 0x007e08c5 main D:\llvm-project\llvm\tools\lli\lli.cpp:643:0 > #6 0x02e12013 invoke_main > d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0 > #7 0x02e11e97 _scrt_common_main_seh > d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0 > #8 0x02e11d2d _scrt_common_main > d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0 > #9 0x02e12098 mainCRTStartup > d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0 > #10 0x75336359 (C:\WINDOWS\System32\KERNEL32.DLL+0x16359) > #11 0x774c8944 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68944) > #12 0x774c8914 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68914) > > What is the best way to debug the 32 bit arch lli.exe under VS2019? > > D:\projects\clang>type hw.c > #include <stdio.h> > int main() { > printf("Hello World!\n"); > return 0; > } > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210310/3fa40214/attachment.html>