[LLVMbugs] [Bug 9080] New: miscompile under -fomit-frame-pointer on x86-64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 27 17:24:23 PST 2011


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

           Summary: miscompile under -fomit-frame-pointer on x86-64
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu


This C testcase from ffmpeg:

  #include <stdio.h>

  int avcodec_alloc_context2() {
    return 123;
  }
  int avcodec_alloc_context(void) {
    return avcodec_alloc_context2();
  }
  int main(void) {
    int ctx = avcodec_alloc_context();
    return printf("%d\n", ctx);
  }

demonstrates some impressive brokenness:

  nlewycky at ducttape:~$ clang x.c -o x -fomit-frame-pointer
  nlewycky at ducttape:~$ ./x
  -1094017336
  nlewycky at ducttape:~$ ./x
  -1472549176
  nlewycky at ducttape:~$ ./x
  1205477064

The reason is the avcodec_alloc_context function stomping on the return value:

  avcodec_alloc_context:                  # @avcodec_alloc_context
  .Leh_func_begin1:
  # BB#0:                                 # %entry
          pushq   %rax
  .Ltmp1:
          callq   avcodec_alloc_context2
          popq    %rax
          ret

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list