Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templight++ -E segfaults #26

Open
cout opened this issue Nov 2, 2015 · 2 comments
Open

templight++ -E segfaults #26

cout opened this issue Nov 2, 2015 · 2 comments

Comments

@cout
Copy link

cout commented Nov 2, 2015

I noticed this when I accidentally ran templight under ccache.

pbrannan@telx-sb-dev2:~/tmp $ /home/pbrannan/bin/templight++-3.7 -c -E test.cpp
0  templight++-3.7 0x00000000010cd7c8
1  templight++-3.7 0x00000000010ccbf9
2  libpthread.so.0 0x00007fe7dec6a340
3  templight++-3.7 0x0000000001ac3b8c
4  templight++-3.7 0x0000000001167556
5  templight++-3.7 0x0000000001188fbf
6  templight++-3.7 0x0000000001168e80
7  templight++-3.7 0x0000000000548bad
8  templight++-3.7 0x00000000005106cd
9  libc.so.6       0x00007fe7dde7dec5 __libc_start_main + 245
10 templight++-3.7 0x0000000000547e24
Stack dump:
0.  Program arguments: /home/pbrannan/bin/templight++-3.7 -c -E test.cpp 
[1]    32025 segmentation fault (core dumped)  /home/pbrannan/bin/templight++-3.7 -c -E test.cpp

Backtrace from gdb:

(gdb) bt
#0  dyn_cast<clang::SemaConsumer, clang::ASTConsumer> (Val=0x0) at /home/pbrannan/download/llvm-3.7.0.src/include/llvm/Support/Casting.h:298
#1  clang::Sema::~Sema (this=0x4fdb820, __in_chrg=<optimized out>) at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/lib/Sema/Sema.cpp:259
#2  0x0000000001167556 in operator() (this=<optimized out>, __ptr=0x4fdb820) at /usr/include/c++/4.8/bits/unique_ptr.h:67
#3  reset (__p=0x4fdb820, this=<optimized out>) at /usr/include/c++/4.8/bits/unique_ptr.h:262
#4  clang::CompilerInstance::setSema (this=<optimized out>, S=<optimized out>) at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/lib/Frontend/CompilerInstance.cpp:102
#5  0x0000000001188fbf in clang::FrontendAction::EndSourceFile (this=this@entry=0x4f93a30) at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/lib/Frontend/FrontendAction.cpp:475
#6  0x0000000001168e80 in clang::CompilerInstance::ExecuteAction (this=this@entry=0x4f8fb10, Act=...)
at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/lib/Frontend/CompilerInstance.cpp:821
#7  0x0000000000548bad in ExecuteTemplightInvocation (Clang=Clang@entry=0x4f8fb10) at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/tools/templight/templight_driver.cpp:400
#8  0x00000000005106cd in ExecuteTemplightCommand (FailingCommands=..., Argv0=<optimized out>, J=..., C=..., Diags=..., TheDriver=...)
at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/tools/templight/templight_driver.cpp:463
#9  main (argc_=<optimized out>, argv_=<optimized out>) at /home/pbrannan/download/llvm-3.7.0.src/tools/clang/tools/templight/templight_driver.cpp:660
@cout
Copy link
Author

cout commented Nov 2, 2015

Oops, incorrect formatting accidentally referenced issues 1-9. Fixed in an edit.

@mikael-s-persson
Copy link
Owner

Well, obviously, running templight with the "-E" option makes no sense at all. This is not something I had expected people would do, there are probably more loop-holes like that. The front-end of templight is something that I wrote in a bit of a quick-and-dirty way that manually instantiates the compiler, so I would imagine that passing in any option that would normally result in the compiler not running at all (like the "-E" option) would interact badly with templight.

Ideally, templight should terminate with an error message instead of crashing on a seg-fault. I would need to find a relatively pain-free way to catch those errors without having to exclude specific options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants