[llvm-bugs] [Bug 44553] New: _allocate bug during JIT linking
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 15 04:48:38 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44553
Bug ID: 44553
Summary: _allocate bug during JIT linking
Product: libraries
Version: 9.0
Hardware: PC
OS: other
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: alexander_shishkin at relex.ru
CC: llvm-bugs at lists.llvm.org
Created attachment 23019
--> https://bugs.llvm.org/attachment.cgi?id=23019&action=edit
Sample code
Steps to reproduce:
1. On Windows in mingw32 ("mingw32/mingw-w64-i686-llvm 8.0.0-8" msys2 package)
environment compile code in attachment with:
gcc -m32 -g -o sum sum.c -lLLVM.dll -lz -lpsapi -lshell32 -lole32 -luuid
-ladvapi32 -lshlwapi -lshlwapi -Wl,-Bstatic -lstdc++ -lws2_32 -lcrypto -lws2_32
2. Run application: ./sum.exe 2 3
It will produce Segmentation fault
Resulting byte code:
ModuleID = 'sum.bc'
source_filename = "my_module"
define i32 @sum(i32, i32)
{ entry: %ret = alloca i32, i32 4096 %tmp = add i32 %0, %1 store i32 %tmp,
i32* %ret %loaded = load i32, i32* %ret ret i32 %loaded }
During the jit linking _alloca function is inserted. This function causes jump
to the next line instead of real stack check and allocation function:
(gdb)
52 if (LLVMCreateExecutionEngineForModule(&engine, mod, &error) != 0)
{
(gdb)
56 if (error) {
(gdb)
62 if (argc < 3) {
(gdb)
66 long long x = strtoll(argv[1], NULL, 10);
(gdb)
67 long long y = strtoll(argv[2], NULL, 10);
(gdb)
69 int (*sum_func)(int, int) = (int (*)(int,
int))LLVMGetFunctionAddress(engine, "sum");
(gdb)
[New Thread 2208.0xa54]
70 int result = sum_func(x, y);
(gdb) p sum_func
$1 = (int (*)(int, int)) 0x3f0000
(gdb) disas 0x3f0000, +200
Dump of assembler code from 0x3f0000 to 0x3f00c8:
0x003f0000: mov $0x4000,%eax
0x003f0005: call 0x3f000a
0x003f000a: mov 0x4004(%esp),%eax
0x003f0011: add 0x4008(%esp),%eax
0x003f0018: mov %eax,(%esp)
0x003f001b: add $0x4000,%esp
0x003f0021: ret
Error is in line 0x003f0005: call 0x3f000a
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200115/12b2a5fe/attachment.html>
More information about the llvm-bugs
mailing list