[cfe-commits] [patch] Fix uninitialized variables causing assert in TokenConcatenation::AvoidConcat

Chris Lattner clattner at apple.com
Tue Jun 15 14:18:23 PDT 2010


On Jun 15, 2010, at 2:01 PM, Michael Spencer wrote:

> On Tue, Jun 15, 2010 at 2:56 PM, Chris Lattner <clattner at apple.com> wrote:
>> 
>> On Jun 14, 2010, at 11:50 PM, Michael Spencer wrote:
>> 
>>> The test case in the attached patch caused an assert to fail in
>>> TokenConcatenation::AvoidConcat due to uninitialized variables in
>>> PrintPreprocessedOutput.cpp/PrintPreprocessedTokens. The rest of the
>>> patch fixes it.
>> 
>> I applied the uninit variable fix in r106025 and testcase in r106026.  The testcase works for me without the other hunk so I left it out.  Thanks!
>> 
>> -Chris
> 
> I still get:

This should be fixed in r106043

-Chris

> 
> C:\Users\Michael\Projects\llvm\tools\clang\test\Frontend>clang
> -fms-extensions -E preprocessed-output-macro-first-token.c
> Assertion failed: ((getOffset()+Offset) & MacroIDBit) == 0 && "invalid
> location", file
> C:\Users\Michael\Projects\llvm\tools\clang\include\clang/Basic/SourceLocation.h,
> line 112
> Stack dump:
> 0.      Program arguments:
> C:/Users/Michael/Projects/llvm-build/VS9/bin/Debug/clang.exe -cc1
> -triple i686-pc-win32 -E -d
> isable-free -main-file-name preprocessed-output-macro-first-token.c
> -mrelocation-model static -mdisable-fp-elim -masm-ve
> rbose -mconstructor-aliases -resource-dir
> C:/Users/Michael/Projects/llvm-build/VS9/bin/lib/clang/2.0
> -ferror-limit 19 -f
> message-length 120 -fms-extensions -fgnu-runtime
> -fdiagnostics-show-option -fcolor-diagnostics -o - -x c
> preprocessed-ou
> tput-macro-first-token.c
> 74F8C355 (0x0000000A 0x0000006C 0x00000000 0x00000000),
> _get_pgmptr()+0453 bytes(s)
> 7502E9AD (0x02EEE5F4 0x02EEE578 0x00000000 0x001C0150), abort()+0045 bytes(s)
> 7501E8D6 (0x01CA2D58 0x01C98030 0x00000070 0x02EEE874), _wassert()+0214 bytes(s)
> 0035222A (0x02EEE5D0 0xCCCCCCCC 0x02EEE5D8 0x02EEE7AC),
> clang::SourceLocation::getFileLocWithOffset()+0074 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\include\clang\basic\sourcelocation.h,
> line 112+0047 byte(s)
> 00B5BD0D (0x02EEE68C 0x02EEE674 0x02EEE81C 0x024A0E10),
> clang::TokenConcatenation::AvoidConcat()+0125 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\lex\tokenconcatenation.cpp,
> line 135+0097 byte(s)
> 003E1525 (0x02EEE68C 0x02EEE674 0x02EEE81C 0xB1F768D7), `anonymous
> namespace'::PrintPPOutputPPCallbacks::AvoidConcat()+0037 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\printpreprocessedoutput.cpp,
> line 131
> 003E0628 (0x02480A20 0x02EEE81C 0x024A0E10 0x02491E10),
> PrintPreprocessedTokens()+0216 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\printpreprocessedoutput.cpp,
> line 432+0056 byte(s)
> 003E04F2 (0x02480A20 0x02491E10 0x024764AC 0xCCCCCCCC),
> clang::DoPrintPreprocessedInput()+0610 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\printpreprocessedoutput.cpp,
> line 540+0021 byte(s)
> 0032BB1A (0xB1F767DB 0x02EEE91C 0x02EEE8BC 0x02EEE86C),
> clang::PrintPreprocessedAction::ExecuteAction()+0122 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\frontendactions.cpp,
> line 192+0027 byte(s)
> 0032CEDA (0xB1F76647 0x02EEF10C 0x02EEE934 0xCCCCCCCC),
> clang::FrontendAction::Execute()+0282 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\frontendaction.cpp,
> line 177+0015 byte(s)
> 0030A66D (0x0247CF68 0xB1F77E77 0x02EEF910 0x00000000),
> clang::CompilerInstance::ExecuteAction()+0717 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\lib\frontend\compilerinstance.cpp,
> line 498
> 002EE904 (0x03059130 0x03059198 0x0305919C 0x002E1794),
> cc1_main()+2004 bytes(s),
> c:\users\michael\projects\llvm\tools\clang\tools\driver\cc1_main.cpp,
> line 288+0027 byte(s)
> 002E328D (0x0000001C 0x03059128 0x030526F0 0xB1F77603), main()+0253
> bytes(s), c:\users\michael\projects\llvm\tools\clang\tools\driver\driver.cpp,
> line 186+0033 byte(s)
> 01646C38 (0x02EEF980 0x75983677 0x7EFDE000 0x02EEF9C0),
> __tmainCRTStartup()+0424 bytes(s),
> f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 582+0025 byte(s)
> 01646A7F (0x7EFDE000 0x02EEF9C0 0x77D39D72 0x7EFDE000),
> mainCRTStartup()+0015 bytes(s),
> f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 399
> 75983677 (0x7EFDE000 0x7D1AC7C1 0x00000000 0x00000000),
> BaseThreadInitThunk()+0018 bytes(s)
> 77D39D72 (0x01646A70 0x7EFDE000 0x00000000 0x00000000),
> RtlInitializeExceptionChain()+0099 bytes(s)
> 77D39D45 (0x01646A70 0x7EFDE000 0x00000000 0x00000000),
> RtlInitializeExceptionChain()+0054 bytes(s)
> clang: error: clang frontend command failed due to signal 2147483645
> (use -v to see invocation)
> 
> Which makes sense considering that in PrintPreprocessedTokens()
> PrevPrevTok and PrevTok are invalid until the while(1) loop is on its
> 3rd iteration. This doesn't happen on every platform because the
> values of PrevPrevTok and PrevTok are undefined. I recommend that
> either PrintPreprocessedTokens() make sure that they are valid before
> they are used, or that a value be given to an invalid token so the
> callee (TokenConcatenation::AvoidConcat() in this case) can decide
> what to do.
> 
> - Michael Spencer





More information about the cfe-commits mailing list