<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Windows/DynamicLibrary: within a Win32/x86 exe, DynamicLibrary::HandleSet::DLSym looks a the wrong UCRT DLL"
   href="https://bugs.llvm.org/show_bug.cgi?id=49535">49535</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Windows/DynamicLibrary: within a Win32/x86 exe, DynamicLibrary::HandleSet::DLSym looks a the wrong UCRT DLL
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Support Libraries
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>francis.andre.kampbell@orange.fr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24622" name="attach_24622" title="The source code">attachment 24622</a> <a href="attachment.cgi?id=24622&action=edit" title="The source code">[details]</a></span>
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 <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> 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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>