[LLVMbugs] [Bug 9779] New: Code from C backend compiled with GCC crashes due to calling functions through pointers to a different function types
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Apr 21 17:23:21 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9779
Summary: Code from C backend compiled with GCC crashes due to
calling functions through pointers to a different
function types
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: maemarcus at gmail.com
CC: llvmbugs at cs.uiuc.edu
Consider the following original code line:
fprintf(stdout, "this fprintf is involved into crash\n");
LLVM translates it to the following IR:
%6 = call i64 bitcast (i64 (i8*, i64, i64, %struct._IO_FILE*)* @fwrite to i64
(i8*, i64, i64, i8*)*)(i8* getelementptr inbounds ([37 x i8]* @.cst2, i64 0,
i64 0), i64 1, i64 36, i8* %5) nounwind
And C backend generates a similar line of C code:
llvm_cbe_tmp__5 = ((unsigned long long (*) (unsigned char *, unsigned long
long , unsigned long long , unsigned char
*))(void*)fwrite)(((&_OC_cst2.array[((signed long long )0ull)])), 1ull, 36ull,
(((unsigned char *)llvm_cbe_tmp__4)));
Now, compiled with gcc, we have:
warning: function called through a non-compatible type
note: if this code is reached, the program will abort
And resulting program will crash with SIGILL (Illegal instruction).
Although, the problem seems to be specific to gcc and specific to code
generation approach involving C backend instead of direct asm generation, it
would be better to make LLVM more accurate about functions typecasting.
--
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