Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Windows/DynamicLibrary: within a Win32/x86 exe, DynamicLibrary::HandleSet::DLSym looks a the wrong UCRT DLL #48504

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49535
Status NEW
Importance P normal
Reported by Francis ANDRE (francis.andre.kampbell@orange.fr)
Reported on 2021-03-11 01:58:26 -0800
Last modified on 2021-03-11 02:14:29 -0800
Version 11.0
Hardware PC Windows NT
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments hw.c (77 bytes, text/plain)
hw-m32.ll (27177 bytes, text/plain)
lli-hw-m32.zip (123971 bytes, application/x-zip-compressed)
mpciihkmmamhbhna.png (156827 bytes, image/png)
Symbol not found ___acrt_iob_func.jpg (517706 bytes, image/jpeg)
Blocks
Blocked by
See also
Created attachment 24622
The source code

Hello

I am running a 32 bit lli.exe with a simple HelloWorld program as
#include <stdio.h>
int main() {
    printf("HelloWorld!\n");
    return 0;
}

and got this stack trace
Assertion failed: OffsetBytes <= AllocationSize && "Offset out of bounds!",
file D:\projects\as400\rpg\llvm-
project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldImpl.h, line 90
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.  Program arguments: D:\\projects\\as400\\rpg\\llvm-
project\\build32\\Debug\\bin\\lli -debug hw-m32.ll
 #0 0x01b9b709 HandleAbort D:\projects\as400\rpg\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x7a53fd98 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x9fd98)
 #2 0x7a5412e2 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa12e2)
 #3 0x7a5456d4 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa56d4)
 #4 0x7a543cca (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa3cca)
 #5 0x7a545c7a (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa5c7a)
 #6 0x01740f07 llvm::SectionEntry::getAddressWithOffset(unsigned int) const D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldImpl.h:90:0
 #7 0x01744c45 llvm::RuntimeDyldCOFFI386::resolveRelocation(class llvm::RelocationEntry const &, unsigned __int64) D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\Targets\RuntimeDyldCOFFI386.h:144:0
 #8 0x01719e58 llvm::RuntimeDyldImpl::resolveRelocationList(class llvm::SmallVector<class llvm::RelocationEntry, 64> const &, unsigned __int64) D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:1082:0
 #9 0x0171d7c9 llvm::RuntimeDyldImpl::resolveLocalRelocations(void) D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:153:0
#10 0x0171d5da llvm::RuntimeDyldImpl::resolveRelocations(void)
D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:139:0
#11 0x0171823d llvm::RuntimeDyld::resolveRelocations(void)
D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyld.cpp:1379:0
#12 0x0144bfa5 llvm::MCJIT::finalizeLoadedModules(void)
D:\projects\as400\rpg\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:245:0
#13 0x0144bdb2 llvm::MCJIT::finalizeObject(void) D:\projects\as400\rpg\llvm-
project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:271:0
#14 0x006f080e main D:\projects\as400\rpg\llvm-
project\llvm\tools\lli\lli.cpp:631:0
#15 0x02d22013 invoke_main
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
#16 0x02d21e97 _scrt_common_main_seh
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#17 0x02d21d2d _scrt_common_main
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#18 0x02d22098 mainCRTStartup
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#19 0x75336359 (C:\WINDOWS\System32\KERNEL32.DLL+0x16359)
#20 0x774c8944 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68944)
#21 0x774c8914 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68914)

In fact, the failed assertion "Assertion failed: OffsetBytes <= AllocationSize
&& "Offset out of bounds!" is a side effect of a unresolved symbol
'___acrt_iob_func' that lli.exe is looking for thru the DynamicLibrary module.

The point is that this external unresolved symbol '___acrt_iob_func' is located
in the C:\Windows\SysWOW64\ucrtbased.dll and is absent from the
C:\Windows\system32\ucrtbased.dll.

Thus, this is an issue. DynalicLibrary should look for all unresolved symbols
in a 32 bit Win32/x86 module into the C:\Windows\SysWOW64 directory and not the
C:\Windows\system32.
Quuxplusone commented 3 years ago

Attached hw.c (77 bytes, text/plain): The source code

Quuxplusone commented 3 years ago

Attached hw-m32.ll (27177 bytes, text/plain): the hw.c translated into hw-m32.ll

Quuxplusone commented 3 years ago

Attached lli-hw-m32.zip (123971 bytes, application/x-zip-compressed): The execution log : build32/bin/lli.exe -debug hw-m32.ll

Quuxplusone commented 3 years ago

Attached mpciihkmmamhbhna.png (156827 bytes, image/png): The stack at the assert failed

Quuxplusone commented 3 years ago

Attached Symbol not found ___acrt_iob_func.jpg (517706 bytes, image/jpeg): Symbol not found: ___acrt_iob_func in RuntimeDyImpl