[LLVMbugs] [Bug 14269] New: clang crashes when trying to get address of the bitfield and generates incorrect code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 6 01:41:06 PST 2012


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

             Bug #: 14269
           Summary: clang crashes when trying to get address of the
                    bitfield and generates incorrect code
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: a.bataev at gmx.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9500
  --> http://llvm.org/bugs/attachment.cgi?id=9500
preprocessed source and associated run script

The following code crashes clang compiled with Asserts

typedef struct foo {
    unsigned int field1 : 1;
    unsigned int field2 : 2;
    unsigned int field3 : 3;
} foo;
foo x;
void bar()
{
    __asm__ ( "movl $5, %0" :
              "=rm" (x.field3));
}
int main()
{
    bar();
    return (x.field3);
}

Here is the report

Assertion failed: (isSimple()), function getAddress, file
/llvm_trunk/llvm/tools/clang/lib/CodeGen/CGValue.h, line 230.
0  clang             0x000000010b904e82 _ZL15PrintStackTracePv + 34
1  clang             0x000000010b905489 _ZL13SignalHandleri + 793
2  libsystem_c.dylib 0x00007fff8ee66cfa _sigtramp + 26
3  libsystem_c.dylib 0x000000010c212f38 _sigtramp + 18446603342617166424
4  clang             0x000000010b9050c6 abort + 22
5  clang             0x000000010b905087 __assert_rtn + 55
6  clang             0x000000010a782711
clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) + 8769
7  clang             0x000000010a77e605
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 565
8  clang             0x000000010a782e6b
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) + 235
9  clang             0x000000010a77e9bd
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 125
10 clang             0x000000010a77e3f9
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 41
11 clang             0x000000010a78f816
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 694
12 clang             0x000000010a798a2d
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 1933
13 clang             0x000000010a795c34
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 340
14 clang             0x000000010a797bca
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 698
15 clang             0x000000010a79d238
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 296
16 clang             0x000000010a7b950f (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 127
17 clang             0x000000010a78c88a
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 170
18 clang             0x000000010a7c67d3 clang::ParseAST(clang::Sema&, bool,
bool) + 323
19 clang             0x000000010a78bc16 clang::CodeGenAction::ExecuteAction() +
1286
20 clang             0x000000010a588e5b clang::FrontendAction::Execute() + 107
21 clang             0x000000010a568f4a
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 986
22 clang             0x000000010a53137c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3388
23 clang             0x000000010a5278fd cc1_main(char const**, char const**,
char const*, void*) + 3005
24 clang             0x000000010a52d2b1 main + 689
25 clang             0x000000010a526d34 start + 52
26 clang             0x000000000000002c start + 18446744069241410348
Stack dump:
0.      Program arguments: /llvm_trunk/build/Release+Asserts/bin/clang -cc1
-triple x86_64-apple-macosx10.7.0 -emit-obj -mrelax-all -disable-free
-main-file-name tr27771.c -pic-level 2 -mdisable-fp-elim -masm-verbose
-munwind-tables -target-cpu core2 -target-linker-version 127.2 -coverage-file
/tr27771.o -resource-dir /llvm_trunk/build/Release+Asserts/bin/../lib/clang/3.2
-fmodule-cache-path
/var/folders/zz/zyxvpxvq6csfxvn_n01bj6140_w9h9/T/clang-module-cache
-fdebug-compilation-dir / -ferror-limit 19 -fmessage-length 157
-stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.7.0
-fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties
-fdiagnostics-show-option -fcolor-diagnostics -o tr27771.o -x c tr27771.c
1.      tr27771.c:17:1: current parser token 'int'
2.      tr27771.c:10:6: LLVM IR generation of declaration 'bar'
3.      tr27771.c:10:6: Generating code for declaration 'bar'
4.      tr27771.c:11:1: LLVM IR generation of compound statement ('{}')
clang: error: unable to execute command: Illegal instruction: 4
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.2 (trunk 166569)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg:
/var/folders/zz/zyxvpxvq6csfxvn_n01bj6140_w9h9/T/tr27771-s6qSaT.c
clang: note: diagnostic msg:
/var/folders/zz/zyxvpxvq6csfxvn_n01bj6140_w9h9/T/tr27771-s6qSaT.sh
clang: note: diagnostic msg:

********************



Clang without asserts generates incorrect code which writes to field3 incorrect
value.


Alexey Bataev
Software Engineer
Intel Compiler Team
Intel Corp.

-- 
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