Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

JIT generated code crash on erroneous null instruction #13511

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR13833
Status REOPENED
Importance P normal
Reported by Eran Weiss (eran.weiss@emc.com)
Reported on 2012-09-13 06:59:56 -0700
Last modified on 2012-10-05 08:25:26 -0700
Version trunk
Hardware Macintosh MacOS X
CC eran.weiss@emc.com, geek4civic@gmail.com, llvm-bugs@lists.llvm.org, mkuper@google.com, nadav.rotem@me.com
Fixed by commit(s)
Attachments bug.c (3048 bytes, application/octet-stream)
Blocks
Blocked by
See also

Created attachment 9201 source code, generates bug

JIT generates code with wrong instructions (which are 0 bytes). These crash (Bus error) when evaluated.

IR: ; ModuleID = 'make_func_module'

define i64 @make_function(i32, i32, i32, i32) { entry: %val = call i64 @void_function() ret i64 %val }

declare i64 @void_function()

ASM: 0x01200030: push %eax 0x01200031: dec %eax 0x01200032: mov $0x10d50,%eax 0x01200037: add %al,(%eax) ## crash 0x01200039: add %al,(%eax) 0x0120003b: call *%eax 0x0120003d: pop %edx 0x0120003e: ret

Source attached. Execution:

/usr/bin/g++ llvm-config --cxxflags -g -m32 -c bug.c /usr/bin/g++ llvm-config --ldflags -g -m32 -o bug bug.o llvm-config --libs all ./bug

Quuxplusone commented 12 years ago

Attached bug.c (3048 bytes, application/octet-stream): source code, generates bug

Quuxplusone commented 12 years ago

I've found the problem - JIT generates code for x86_64 while the program is in x86 mode.

However, llvm-c ignores the module Triple. Note that the code attached doesn't specify a Triple, but the crash remains when the correct Triple is specified.

I have a patch, and I'll send it to llvm-commits.

Quuxplusone commented 12 years ago

I reopened this. Let's close it when the patch goes in, because we need to note the revision in which this bug is fixed.