LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 16344 - Crash on parsing customized "vfprintf"
Summary: Crash on parsing customized "vfprintf"
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-17 02:59 PDT by WenHan Gu
Modified: 2013-06-25 20:00 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
patch_r2_20130617 (2.55 KB, patch)
2013-06-18 09:17 PDT, WenHan Gu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description WenHan Gu 2013-06-17 02:59:24 PDT
$ cat test.c
void vfprintf() {}  // Only one line in source

This only occurs for this function. If I write "void fprintf();", everything works except for warning.

Clang 3.2 is good for this too.


$ clang -c test.c
test.c:1:6: warning: incompatible redeclaration of library function 'vfprintf' [-Wincompatible-library-redeclaration]
void vfprintf() {}
     ^
test.c:1:6: note: 'vfprintf' is a builtin with type 'int ()'
0  clang           0x0000000002454ef2 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1  clang           0x0000000002456f42
2  libpthread.so.0 0x00007f723963e8f0
3  clang           0x0000000000b8b38e clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Decl*) + 2814
4  clang           0x0000000000a63342 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Pars
er::LateParsedAttrList*) + 4930
5  clang           0x0000000000a788a9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRa
ngeInit*) + 2521
6  clang           0x0000000000a5e139 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang
::AccessSpecifier) + 249
7  clang           0x0000000000a5e83e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*,
 clang::AccessSpecifier) + 1022
8  clang           0x0000000000a5fb71 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 97
9  clang           0x0000000000a60612 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 194
10 clang           0x0000000000a56d60 clang::ParseAST(clang::Sema&, bool, bool) + 288
11 clang           0x00000000008acc05 clang::CodeGenAction::ExecuteAction() + 101
12 clang           0x000000000071d359 clang::FrontendAction::Execute() + 313
13 clang           0x00000000006f92e5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 341
14 clang           0x00000000006dd997 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1543
15 clang           0x00000000006d3408 cc1_main(char const**, char const**, char const*, void*) + 1272
16 clang           0x00000000006db493 main + 7651
17 libc.so.6       0x00007f723870dc4d __libc_start_main + 253
18 clang           0x00000000006d2d29
Stack dump:
0.      Program arguments: /proj/mtk03872/usr/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.20.1 -coverage-file /proj/mtk03872/test.o -resource-dir /proj/mtk03872/usr/bin/../lib/clang/3.4 -internal-isystem /usr/local/include -internal-isystem /proj/mtk03872/usr/bin/../lib/clang/3.4/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /proj/mtk03872 -ferror-limit 19 -fmessage-length 157 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o test.o -x c test.c
1.      test.c:1:17: current parser token '{'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.4 (http://llvm.org/git/clang.git 375a040d49049c90b29b80cde480025f4ba5a717) (http://llvm.org/git/llvm.git 7338de37a802970857079b5a532c5dd50d0a6d5d)
Target: x86_64-unknown-linux-gnu
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: /tmp/test-WpMbm8.c
clang: note: diagnostic msg: /tmp/test-WpMbm8.sh
clang: note: diagnostic msg:

********************
Comment 1 WenHan Gu 2013-06-17 03:04:21 PDT
BTW, "void vfprintf();" is good, but "void vfprintf() {}" crashes.
Comment 2 WenHan Gu 2013-06-17 06:38:15 PDT
I've found this bug is introduced by 8a0086cfd21e5a89f96715d7a504178c5fc0ca26

Keep digging.
Comment 3 WenHan Gu 2013-06-18 09:17:13 PDT
Created attachment 10697 [details]
patch_r2_20130617

For convenient to check patch
Comment 4 WenHan Gu 2013-06-25 20:00:28 PDT
Fixed at r184875 and r184887. Thanks!