-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[cling] Crash unloading a templated function containing a lambda expression #9850
Comments
Cannot reproduce with a recent master build on Fedora 35
|
Good morning,
and thanks for the check!
When I try it on a Linux system where I have access to, the macro crashes. So it occurs not only on OSX but also on Linux.
It would be interesting to know whether the problem can be fixed by installing a later version of ROOT, and if so, if the fix is already implemented in one of the official releases.
The latest version I see on https://root.cern/install/all_releases/ is 6.24/06, so a test with 6.27/01 may or may not be relevant for the community.
Best regards,
Michael
prompt> root -b
-------------------------------------------------------------------------
| Welcome to ROOT 6.06/08 http://root.cern.ch |
| (c) 1995-2016, The ROOT Team |
| Built for linuxx8664gcc |
| From ***@***.***, Sep 01 2016, 14:28:05 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
-------------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x000000356faac89e in waitpid () from /lib64/libc.so.6
#1 0x000000356fa3e4e9 in do_system () from /lib64/libc.so.6
#2 0x00007fbb22a2912f in TUnixSystem::StackTrace() () from /opt/ROOTv668/lib/root/libCore.so
#3 0x00007fbb22a2b93c in TUnixSystem::DispatchSignals(ESignals) () from /opt/ROOTv668/lib/root/libCore.so
#4 <signal handler called>
#5 0x00007fbb2095648d in clang::CXXRecordDecl::getLambdaCallOperator() const () from /opt/ROOTv668/lib/root/libCling.so
#6 0x00007fbb1ff8d996 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseLambdaExpr(clang::LambdaExpr*) () from /opt/ROOTv668/lib/root/libCling.so
#7 0x00007fbb200bdc79 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseStmt(clang::Stmt*) () from /opt/ROOTv668/lib/root/libCling.so
#8 0x00007fbb1ff8dd19 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr*) () from /opt/ROOTv668/lib/root/libCling.so
#9 0x00007fbb200bdc55 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseStmt(clang::Stmt*) () from /opt/ROOTv668/lib/root/libCling.so
#10 0x00007fbb1ff8b4b4 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseCXXConstructExpr(clang::CXXConstructExpr*) () from /opt/ROOTv668/lib/root/libCling.so
#11 0x00007fbb200bdfeb in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseStmt(clang::Stmt*) () from /opt/ROOTv668/lib/root/libCling.so
#12 0x00007fbb200bc1be in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseDecl(clang::Decl*) () from /opt/ROOTv668/lib/root/libCling.so
#13 0x00007fbb1ff8a658 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseDeclStmt(clang::DeclStmt*) () from /opt/ROOTv668/lib/root/libCling.so
#14 0x00007fbb200be0d6 in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseStmt(clang::Stmt*) () from /opt/ROOTv668/lib/root/libCling.so
#15 0x00007fbb1ff8ab9d in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseCompoundStmt(clang::CompoundStmt*) () from /opt/ROOTv668/lib/root/libCling.so
#16 0x00007fbb200be0fa in clang::RecursiveASTVisitor<clang::(anonymous namespace)::StaticVarCollector>::TraverseStmt(clang::Stmt*) () from /opt/ROOTv668/lib/root/libCling.so
#17 0x00007fbb200becb3 in clang::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*) () from /opt/ROOTv668/lib/root/libCling.so
#18 0x00007fbb200bfe5b in cling::TransactionUnloader::RevertTransaction(cling::Transaction*) () from /opt/ROOTv668/lib/root/libCling.so
#19 0x00007fbb20097728 in cling::IncrementalParser::rollbackTransaction(cling::Transaction*) () from /opt/ROOTv668/lib/root/libCling.so
#20 0x00007fbb2009de9b in cling::Interpreter::unload(unsigned int) () from /opt/ROOTv668/lib/root/libCling.so
#21 0x00007fbb200e53a9 in cling::MetaSema::actOnUCommand(llvm::StringRef) () from /opt/ROOTv668/lib/root/libCling.so
#22 0x00007fbb200e8eff in cling::MetaSema::actOnLCommand(llvm::StringRef, cling::Transaction**) () from /opt/ROOTv668/lib/root/libCling.so
#23 0x00007fbb200e90c5 in cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) () from /opt/ROOTv668/lib/root/libCling.so
#24 0x00007fbb200e1329 in cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /opt/ROOTv668/lib/root/libCling.so
#25 0x00007fbb200e22ee in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /opt/ROOTv668/lib/root/libCling.so
#26 0x00007fbb200e2d5b in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /opt/ROOTv668/lib/root/libCling.so
#27 0x00007fbb1ffa1edd in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /opt/ROOTv668/lib/root/libCling.so
#28 0x00007fbb1ff902db in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /opt/ROOTv668/lib/root/libCling.so
#29 0x00007fbb2294dcbc in TApplication::ExecuteFile(char const*, int*, bool) () from /opt/ROOTv668/lib/root/libCore.so
#30 0x00007fbb2294d232 in TApplication::ProcessLine(char const*, bool, int*) () from /opt/ROOTv668/lib/root/libCore.so
#31 0x00007fbb22581645 in TRint::ProcessLineNr(char const*, char const*, int*) () from /opt/ROOTv668/lib/root/libRint.so
#32 0x00007fbb225818a1 in TRint::HandleTermInput() () from /opt/ROOTv668/lib/root/libRint.so
#33 0x00007fbb22a2af45 in TUnixSystem::CheckDescriptors() () from /opt/ROOTv668/lib/root/libCore.so
#34 0x00007fbb22a2c06a in TUnixSystem::DispatchOneEvent(bool) () from /opt/ROOTv668/lib/root/libCore.so
#35 0x00007fbb229aadf6 in TSystem::InnerLoop() () from /opt/ROOTv668/lib/root/libCore.so
#36 0x00007fbb229ab9e0 in TSystem::Run() () from /opt/ROOTv668/lib/root/libCore.so
#37 0x00007fbb2294b12f in TApplication::Run(bool) () from /opt/ROOTv668/lib/root/libCore.so
#38 0x00007fbb22582d77 in TRint::Run(bool) () from /opt/ROOTv668/lib/root/libRint.so
#39 0x000000000040128c in main ()
===========================================================
…--
Michael Schmelling, MPI for Nuclear Physics
Phone:+49-6221-516-511 Fax:+49-6221-516-603
On 9. Feb 2022, at 23:49, Vincenzo Eduardo Padulano ***@***.***> wrote:
Cannot reproduce with a recent master build on Fedora 35
(base) ***@***.*** [~]: cat crash.cc
#include <stdio.h>
template <typename T> auto square(T x) {
auto crash = [](double x) {return x;};
return x*x;
}
void crash()
{
printf("%d\n",square(2));
}
(base) ***@***.*** [~]: root
------------------------------------------------------------------
| Welcome to ROOT 6.27/01 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Feb 06 2022, 22:51:00 |
| From ***@***.*** |
| With c++ (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7) |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
4
root [2] .x crash.cc
4
root [3] .x crash.cc
4
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.
|
Works on lxplus with latest ROOT release 6.24.06 (6.26 is due soon)
|
thanks!
one problem less :-)
…--
Michael Schmelling, MPI for Nuclear Physics
Phone:+49-6221-516-511 Fax:+49-6221-516-603
On 10. Feb 2022, at 11:29, Vincenzo Eduardo Padulano ***@***.***> wrote:
Works on lxplus with latest ROOT release 6.24.06 (6.26 is due soon)
***@***.*** ~]$source /cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos7-gcc11-opt/setup.sh
***@***.*** ~]$root --version
ROOT Version: 6.24/06
Built for linuxx8664gcc on Sep 02 2021, 14:20:23
From ***@***.***
***@***.*** ~]$cat crash.cc
#include <stdio.h>
template <typename T> auto square(T x) {
auto crash = [](double x) {return x;};
return x*x;
}
void crash()
{
printf("%d\n",square(2));
}
***@***.*** ~]$root
------------------------------------------------------------------
| Welcome to ROOT 6.24/06 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Sep 02 2021, 14:20:23 |
| From ***@***.*** |
| With g++ (GCC) 11.1.0 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
4
root [2] .x crash.cc
4
root [3] .x crash.cc
4
root [4] .x crash.cc
4
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.
|
Four our reference, found the issue in ROOT 6.22.06 on lxplus with a debug build
We are probably missing some backport, to be decided if it is needed. |
Hi - now also tried 6.24/06:
prompt> root --version
ROOT Version: 6.24/06
Built for macosx64 on Sep 02 2021, 14:20:23
From ***@***.***
unfortunately, for me the problem persists...
root [0] .x crash.cc
4
root [1] .x crash.cc
*** Break *** segmentation violation
etc....
…--
Michael Schmelling, MPI for Nuclear Physics
Phone:+49-6221-516-511 Fax:+49-6221-516-603
On 10. Feb 2022, at 11:34, Vincenzo Eduardo Padulano ***@***.***> wrote:
Four our reference, found the issue in ROOT 6.22.06 on lxplus with a debug build
***@***.*** ~]$source /cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc10-dbg/setup.sh
***@***.*** ~]$root --version
ROOT Version: 6.22/06
Built for linuxx8664gcc on Nov 27 2020, 15:14:08
From ***@***.***
***@***.*** ~]$cat crash.cc
#include <stdio.h>
template <typename T> auto square(T x) {
auto crash = [](double x) {return x;};
return x*x;
}
void crash()
{
printf("%d\n",square(2));
}
***@***.*** ~]$root
------------------------------------------------------------------
| Welcome to ROOT 6.22/06 https://root.cern |
| (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Nov 27 2020, 15:14:08 |
| From ***@***.*** |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
root.exe: /build/jenkins/workspace/lcg_release_pipeline/build/projects/ROOT-v6.22.06/src/ROOT/v6.22.06/interpreter/llvm/src/tools/clang/lib/AST/DeclCXX.cpp:1106: clang::CXXMethodDecl* clang::CXXRecordDecl::getLambdaCallOperator() const: Assertion `!Calls.empty() && "Missing lambda call operator!"' failed.
We are probably missing some backport, to be decided if it is needed.
@michael-mpik if possible please upgrade to the latest ROOT version and let us know if the problem persists. Thanks again for your report 😄
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
I tried on one of our CI nodes with MacOS 10.15 at the tip of the 6.24 branch and still the problem is not shown.
In your example above, |
good morning!
I tried with root 6.24/06, and installed either as .pkg or from tar.gz - both with the same result. I will do some more tests, and in particular also try to upgrade Xcode11 to Xcode12, and let you know.
…--
Michael Schmelling, MPI for Nuclear Physics
Phone:+49-6221-516-511 Fax:+49-6221-516-603
On 10. Feb 2022, at 21:28, Vincenzo Eduardo Padulano ***@***.***> wrote:
I tried on one of our CI nodes with MacOS 10.15 at the tip of the 6.24 branch and still the problem is not shown.
macitois19:6-24 sftnight$ root
------------------------------------------------------------------
| Welcome to ROOT 6.24/07 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosx64 on Feb 09 2022, 23:19:43 |
| From ***@***.*** |
| With Apple clang version 12.0.0 (clang-1200.0.32.28) |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
4
root [2] .x crash.cc
4
root [3] .x crash.cc
4
In your example above, From ***@***.*** looks quite weird to me. To better understand the differences, it would be helpful to know how you installed ROOT.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
I now installed Xcode 12.4 (12D4e) and root6.24/06 from root_v6.24.06.macos-10.15-x86_64-clang120.pkg. My system is macOS Catalina 10.15.6. Here is what I get:
root [0] .x crash.cc
4
root [1] .x crash.cc
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/Applications/root_v6.24.06/lib/libCling.6.24.06.so] clang::RecursiveASTVisitor<cling::(anonymous namespace)::StaticVarCollector>::dataTraverseNode(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) (no debug info)
...
…--
Michael Schmelling, MPI for Nuclear Physics
Phone:+49-6221-516-511 Fax:+49-6221-516-603
On 10. Feb 2022, at 21:28, Vincenzo Eduardo Padulano ***@***.***> wrote:
I tried on one of our CI nodes with MacOS 10.15 at the tip of the 6.24 branch and still the problem is not shown.
macitois19:6-24 sftnight$ root
------------------------------------------------------------------
| Welcome to ROOT 6.24/07 https://root.cern |
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosx64 on Feb 09 2022, 23:19:43 |
| From ***@***.*** |
| With Apple clang version 12.0.0 (clang-1200.0.32.28) |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x crash.cc
4
root [1] .x crash.cc
4
root [2] .x crash.cc
4
root [3] .x crash.cc
4
In your example above, From ***@***.*** looks quite weird to me. To better understand the differences, it would be helpful to know how you installed ROOT.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
Thanks for reporting @michael-mpik. I have reproduced the problem and a PR is on its way. |
TLDR; for reference, the issue is described below. Implicit instantiation of a function template calls This is by design. However, unloading of decls in the transaction should not process the same |
…ssed only once Implicit instantiation of a function template calls `DeclCollector::HandleCXXImplicitFunctionInstantiation()`, which appends the FunctionDecl to the transaction. According to clang documentation, the body of the function has not yet been instantiated. `HandleTopLevelDecl()` will be called again for this decl at the end of the TU, which will append it again to the transaction - same `Decl *`, different ConsumerCallInfo. This is by design. However, unloading of decls in the transaction should not process the same `Decl *` twice. In particular, entries with ConsumerCallInfo == `kCCIHandleCXXImplicitFunctionInstantiation` will omitted. Fixes issue root-project#9850.
…ssed only once Implicit instantiation of a function template calls `DeclCollector::HandleCXXImplicitFunctionInstantiation()`, which appends the FunctionDecl to the transaction. According to clang documentation, the body of the function has not yet been instantiated. `HandleTopLevelDecl()` will be called again for this decl at the end of the TU, which will append it again to the transaction - same `Decl *`, different ConsumerCallInfo. This is by design. However, unloading of decls in the transaction should not process the same `Decl *` twice. In particular, entries with ConsumerCallInfo == `kCCIHandleCXXImplicitFunctionInstantiation` will omitted. Fixes issue root-project#9850.
…ssed only once Implicit instantiation of a function template calls `DeclCollector::HandleCXXImplicitFunctionInstantiation()`, which appends the FunctionDecl to the transaction. According to clang documentation, the body of the function has not yet been instantiated. `HandleTopLevelDecl()` will be called again for this decl at the end of the TU, which will append it again to the transaction - same `Decl *`, different ConsumerCallInfo. This is by design. However, unloading of decls in the transaction should not process the same `Decl *` twice. In particular, entries with ConsumerCallInfo == `kCCIHandleCXXImplicitFunctionInstantiation` will omitted. Fixes issue root-project#9850.
…ssed only once Implicit instantiation of a function template calls `DeclCollector::HandleCXXImplicitFunctionInstantiation()`, which appends the FunctionDecl to the transaction. According to clang documentation, the body of the function has not yet been instantiated. `HandleTopLevelDecl()` will be called again for this decl at the end of the TU, which will append it again to the transaction - same `Decl *`, different ConsumerCallInfo. This is by design. However, unloading of decls in the transaction should not process the same `Decl *` twice. In particular, entries with ConsumerCallInfo == `kCCIHandleCXXImplicitFunctionInstantiation` will omitted. Fixes issue #9850.
// cling problem with lambda functions inside of template functions
//
// A code fragment illustrating the problem is given below.
// Starting ROOT and running the macro once works, running it
// a second time produces a crash. Commenting the (not-even used)
// lambda function avoid the crash. The macro can be run as often as
// one likes.
//
// ROOT 6.20/02 on MacOSX 10.15.06
// root [1] .x crash.cc -> works
// root [2] .x crash.cc -> crash
template T square(T x) {
auto crash = [](double x) {return x;}; // comment this line to avoid the crash
return x*x;
}
void crash()
{
printf("%d\n",square(2));
}
The text was updated successfully, but these errors were encountered: