[LLVMbugs] [Bug 18438] New: Trivial optimized code crashes on memory modification

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 9 23:47:38 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18438

            Bug ID: 18438
           Summary: Trivial optimized code crashes on memory modification
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vitaly at grechko.ru
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11859
  --> http://llvm.org/bugs/attachment.cgi?id=11859&action=edit
Slightly modified clang-interpreter example that reproduced the bug

Hi,
First of all, thank you for great library!
I've been successfully using JIT based on clang/examples/clang-interpreter many
years but now found a huge stopper. I spent 3 weeks localizing the problem and
did my best of reducing the case.

Summary:
Need Linux 64 bit (Windows is OK), LLVM versions tested 3.4,3.3,3.2.
If we write a function "f" in separate file crash_f.c that takes array of
integers and fills it (e.g. with zeros)

int f(int n,int* a) {
    for (int i=0; i<n; ++i) a[i] = 0;
    return 0;
}

then take tools/clang/examples/clang-interpeter, allocate array of integers
there (e.g. "new int[115]") then compile crash_f.c WITH OPTIMIZATION, take
pointer to "f" and pass this array to "f",

then compile clang-interpreter with -static option,
we got Segmentation Fault!

The problems disappeares if one of the conditions ommited:
- Args.push_back("-O2"); // add optimization to clang
- memory modification in function "f"
- compile clang-interpreter with -static
- Linux 64 bit

I prepared all the files for you to reproduce the bug:

How to reproduce:
1. LLVM version: 3.4
2. OS: any Linux (Ubuntu, Centos, ...)
3. Take slightly modified clang-interpreter example (attached main.cpp),
Makefile (attached), crash_f.c (attached)
4. Open Makefile and modify first 2 lines to your LLVM path and LLVM-build
path.
5. run "make" which should build a "crash" executable
6. run "./crash -c crash_f.c" - should be Segmentation fault

Thanks!

-- 
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/20140110/dac9f6a5/attachment.html>


More information about the llvm-bugs mailing list