Skip to content

.undo back beyond the first definition -- crash 1.4-dev #561

@Twenkid

Description

@Twenkid

Built from source on Lubuntu 24.04;
I tested what is possible to be redefined, e.g. I tried to redefine classes, then .undo etc. When the undo reaches the bottom, the session crashes. On 1.2 binary it says "Can't unload ... " etc.
If there is nothing defined in a new session, .undo returns the expected message.
Also, the crash possibly come after there are errors or warnings in the declaration. In another run it worked fine (see last log).

(I saw a 2024 issue for another crashes after undo of evaluations without semicolon: #522)
This one seems to be related as in the latest shown session the undo lead to crash after such transactions before that.

~/Downloads/cling-build$ ./bin/cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ class C {
[cling]$ ?   public: int a;           
[cling]$ ?   C(int x){ a=x;}
[cling]$ ?   };
[cling]$ 
[cling]$ C c(3);
[cling]$ c     
(C &) @0x7aad57555000
[cling]$ c.x
input_line_7:2:4: error: no member named 'x' in 'C'
 c.x
 ~ ^
[cling]$ c.a                                                                                                                                           
(int) 3
[cling]$ class C { 
[cling]$ ?   public: int a,b;
[cling]$ ?   C(int x,y){a=x; b=y*x;}
[cling]$ ?   };    
input_line_9:1:7: error: redefinition of 'C'
class C {
      ^
input_line_3:1:7: note: previous definition is here                                                                                                    
class C {
      ^
[cling]$ .undo                                                                                                                                         
[cling]$ C
input_line_10:2:2: warning: declaration does not declare anything [-Wmissing-declarations]
 C
 ^
[cling]$ class C { public: char c;                                                                                                                     
[cling]$ ?   C(){ c = 'a';}
[cling]$ ?   };
input_line_11:1:7: error: redefinition of 'C'
class C { public: char c; 
      ^
input_line_3:1:7: note: previous definition is here                                                                                                    
class C {
      ^
[cling]$ .undo                                                                                                                                         
[cling]$ .undo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x0000594a260efe92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x0000594a260ed356
2  libc.so.6 0x00007aad56c45330
3  cling     0x0000594a28481eb3 clang::BaseUsingDecl::removeShadowDecl(clang::UsingShadowDecl*) + 35
4  cling     0x0000594a25f87167 cling::DeclUnloader::VisitUsingShadowDecl(clang::UsingShadowDecl*) + 39
5  cling     0x0000594a25f87dcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
6  cling     0x0000594a25f87f2b cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*, bool) + 91
7  cling     0x0000594a25f87dcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
8  cling     0x0000594a25f88860 cling::DeclUnloader::VisitTagDecl(clang::TagDecl*) + 32
9  cling     0x0000594a25f88ae7 cling::DeclUnloader::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 39
10 cling     0x0000594a26013fa5 cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) + 517
11 cling     0x0000594a2601449e cling::TransactionUnloader::RevertTransaction(cling::Transaction*) + 542
12 cling     0x0000594a25fe58dc cling::Interpreter::unload(cling::Transaction&) + 492
13 cling     0x0000594a25fe5a0d cling::Interpreter::unload(unsigned int) + 93
14 cling     0x0000594a26038c80 cling::MetaSema::actOnUndoCommand(unsigned int) + 16
15 cling     0x0000594a26034e9b cling::MetaParser::isundoCommand() + 187
16 cling     0x0000594a260357d9 cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) + 633
17 cling     0x0000594a26036390 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 480
18 cling     0x0000594a26113bbf cling::UserInterface::runInteractively(bool) + 623
19 cling     0x0000594a25debe91 main + 3073
20 libc.so.6 0x00007aad56c2a1ca
21 libc.so.6 0x00007aad56c2a28b __libc_start_main + 139
22 cling     0x0000594a25eda2e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
Segmentation fault (core dumped)
~/Downloads/cling-build$ 
~/Downloads/cling-build$ ./bin/cling --version
1.4~dev
~/Downloads/cling-build$ ./bin/cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
....                                                                                                                           
[cling]$ class C { public: C() {} };                                                                                                                   
[cling]$ C c();
input_line_5:2:5: warning: empty parentheses interpreted as a function declaration [-Wvexing-parse]
....
[cling]$ class C{ public: int a; C() { a = 34; } };                                                                                                    
input_line_12:1:7: error: redefinition of 'C'
class C{ public: int a; C() { a = 34; } };
      ^
input_line_4:1:7: note: previous definition is here                                                                                                    
class C { public: C() {} };
      ^
[cling]$ C c;                                                                                                                                          
input_line_13:2:4: error: redefinition of 'c' as different kind of symbol
 C c;
   ^
input_line_5:2:4: note: previous definition is here                                                                                                    
 C c();
   ^
[cling]$ C d;                                                                                                                                          
[cling]$ c
input_line_15:2:2: error: use of undeclared identifier 'c'
 c
 ^
[cling]$ .undo                                                                                                                                         
[cling]$ int d;
[cling]$ int d;
input_line_17:2:6: error: redefinition of 'd'
 int d;
     ^
input_line_16:2:6: note: previous definition is here                                                                                                   
 int d;
     ^
[cling]$ .undo                                                                                                                                         
[cling]$ .undo
[cling]$ .undo
[cling]$ C c;
[cling]$ c
(C &) @0x7e0f474b3000
[cling]$ .undo
[cling]$ .undo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x000064ae0ebbee92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x000064ae0ebbc356
2  libc.so.6 0x00007e0f46e45330
3  cling     0x000064ae10f50eb3 clang::BaseUsingDecl::removeShadowDecl(clang::UsingShadowDecl*) + 35
4  cling     0x000064ae0ea56167 cling::DeclUnloader::VisitUsingShadowDecl(clang::UsingShadowDecl*) + 39
5  cling     0x000064ae0ea56dcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
6  cling     0x000064ae0ea56f2b cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*, bool) + 91
7  cling     0x000064ae0ea56dcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
8  cling     0x000064ae0ea57860 cling::DeclUnloader::VisitTagDecl(clang::TagDecl*) + 32
9  cling     0x000064ae0ea57ae7 cling::DeclUnloader::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 39
10 cling     0x000064ae0eae2fa5 cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) + 517
11 cling     0x000064ae0eae349e cling::TransactionUnloader::RevertTransaction(cling::Transaction*) + 542
12 cling     0x000064ae0eab48dc cling::Interpreter::unload(cling::Transaction&) + 492
13 cling     0x000064ae0eab4a0d cling::Interpreter::unload(unsigned int) + 93
14 cling     0x000064ae0eb07c80 cling::MetaSema::actOnUndoCommand(unsigned int) + 16
15 cling     0x000064ae0eb03e9b cling::MetaParser::isundoCommand() + 187
16 cling     0x000064ae0eb047d9 cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) + 633
17 cling     0x000064ae0eb05390 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 480
18 cling     0x000064ae0ebe2bbf cling::UserInterface::runInteractively(bool) + 623
19 cling     0x000064ae0e8bae91 main + 3073
20 libc.so.6 0x00007e0f46e2a1ca
21 libc.so.6 0x00007e0f46e2a28b __libc_start_main + 139
22 cling     0x000064ae0e9a92e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
Segmentation fault (core dumped)
~/Downloads/cling-build$ ./bin/cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ class D { char c; public: D(char d='a'){c = d;} };
[cling]$ D d;
[cling]$ d
(D &) @0x70df6325b000
[cling]$ D
input_line_7:2:2: warning: declaration does not declare anything [-Wmissing-declarations]
 D
 ^
[cling]$ .undo                                                                                                                                         
[cling]$ .undo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x00006407b7156e92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x00006407b7154356
2  libc.so.6 0x000070df62a45330
3  cling     0x00006407b94e8eb3 clang::BaseUsingDecl::removeShadowDecl(clang::UsingShadowDecl*) + 35
4  cling     0x00006407b6fee167 cling::DeclUnloader::VisitUsingShadowDecl(clang::UsingShadowDecl*) + 39
5  cling     0x00006407b6feedcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
6  cling     0x00006407b6feef2b cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*, bool) + 91
7  cling     0x00006407b6feedcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
8  cling     0x00006407b6fef860 cling::DeclUnloader::VisitTagDecl(clang::TagDecl*) + 32
9  cling     0x00006407b6fefae7 cling::DeclUnloader::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 39
10 cling     0x00006407b707afa5 cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) + 517
11 cling     0x00006407b707b49e cling::TransactionUnloader::RevertTransaction(cling::Transaction*) + 542
12 cling     0x00006407b704c8dc cling::Interpreter::unload(cling::Transaction&) + 492
13 cling     0x00006407b704ca0d cling::Interpreter::unload(unsigned int) + 93
14 cling     0x00006407b709fc80 cling::MetaSema::actOnUndoCommand(unsigned int) + 16
15 cling     0x00006407b709be9b cling::MetaParser::isundoCommand() + 187
16 cling     0x00006407b709c7d9 cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) + 633
17 cling     0x00006407b709d390 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 480
18 cling     0x00006407b717abbf cling::UserInterface::runInteractively(bool) + 623
19 cling     0x00006407b6e52e91 main + 3073
20 libc.so.6 0x000070df62a2a1ca
21 libc.so.6 0x000070df62a2a28b __libc_start_main + 139
22 cling     0x00006407b6f412e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
Segmentation fault (core dumped)
~/Downloads/cling-build$ lsb_release -a or cat /etc/os-releas
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble

These two sessions don't crash:

./bin/cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ bin c;
input_line_3:2:2: error: unknown type name 'bin'
 bin c;
 ^
[cling]$ int c;                                                                                                                                        
[cling]$ Class A{ public: A(){} };
input_line_5:2:2: error: use of undeclared identifier 'Class'; did you mean 'class'?
 Class A{ public: A(){} };
 ^~~~~
 class                                                                                                                                                 
[cling]$ class A {public: A(){} };                                                                                                                     
[cling]$ A a;
[cling]$ A b();
input_line_8:2:5: warning: empty parentheses interpreted as a function declaration [-Wvexing-parse]
 A b();
    ^~
input_line_8:2:5: note: remove parentheses to declare a variable                                                                                       
 A b();
    ^~
[cling]$ b                                                                                                                                             
input_line_9:2:2: error: use of undeclared identifier 'b'
 b
 ^
[cling]$ void b(){}                                                                                                                                    
input_line_10:1:6: error: functions that differ only in their return type cannot be overloaded
void b(){}
~~~~ ^
input_line_8:2:4: note: previous declaration is here                                                                                                   
 A b();
 ~ ^
[cling]$ A b(){int a=34;}                                                                                                                              
input_line_11:1:16: error: non-void function does not return a value [-Werror,-Wreturn-type]
A b(){int a=34;}
               ^
[cling]$ A b(){int a=34; A a1; retun a1;}                                                                                                              
input_line_12:1:23: error: use of undeclared identifier 'retun'; did you mean 'return'?
A b(){int a=34; A a1; retun a1;}
                      ^~~~~
                      return                                                                                                                           
[cling]$ A b(){int a=34; A a1; return a1;}                                                                                                             
[cling]$ .undo
[cling]$ .undo
[cling]$ .undo
[cling]$ .undo
[cling]$ .undo
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ .undo 
cling: Can't unload first transaction!  Unloaded 0 of 1

Crash again

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ class C{ public: C(){ int a=34;}};
[cling]$ .undo
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ C c();
input_line_4:2:2: error: unknown type name 'C'
 C c();
 ^
input_line_4:2:5: warning: empty parentheses interpreted as a function declaration [-Wvexing-parse]                                                    
 C c();
    ^~
input_line_4:2:5: note: replace parentheses with an initializer to declare a variable                                                                  
 C c();
    ^~
     = 0                                                                                                                                               
[cling]$ .undo                                                                                                                                         
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ .undo
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ c
input_line_5:2:2: error: use of undeclared identifier 'c'
 c
 ^
[cling]$ .undo                                                                                                                                         
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ C d;
input_line_6:2:2: error: unknown type name 'C'
 C d;
 ^
[cling]$ .undo                                                                                                                                         
cling: Can't unload first transaction!  Unloaded 0 of 1
[cling]$ class C{ public: C(){ int a=34;}};
[cling]$ C c
(C &) @0x7670c5c3e000
[cling]$ .undo
[cling]$ .undo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x00005c22076c2e92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x00005c22076c0356
2  libc.so.6 0x00007670c5445330
3  cling     0x00005c2209a54eb3 clang::BaseUsingDecl::removeShadowDecl(clang::UsingShadowDecl*) + 35
4  cling     0x00005c220755a167 cling::DeclUnloader::VisitUsingShadowDecl(clang::UsingShadowDecl*) + 39
5  cling     0x00005c220755adcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
6  cling     0x00005c220755af2b cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*, bool) + 91
7  cling     0x00005c220755adcc cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) + 284
8  cling     0x00005c220755b860 cling::DeclUnloader::VisitTagDecl(clang::TagDecl*) + 32
9  cling     0x00005c220755bae7 cling::DeclUnloader::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 39
10 cling     0x00005c22075e6fa5 cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) + 517
11 cling     0x00005c22075e749e cling::TransactionUnloader::RevertTransaction(cling::Transaction*) + 542
12 cling     0x00005c22075b88dc cling::Interpreter::unload(cling::Transaction&) + 492
13 cling     0x00005c22075b8a0d cling::Interpreter::unload(unsigned int) + 93
14 cling     0x00005c220760bc80 cling::MetaSema::actOnUndoCommand(unsigned int) + 16
15 cling     0x00005c2207607e9b cling::MetaParser::isundoCommand() + 187
16 cling     0x00005c22076087d9 cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) + 633
17 cling     0x00005c2207609390 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 480
18 cling     0x00005c22076e6bbf cling::UserInterface::runInteractively(bool) + 623
19 cling     0x00005c22073bee91 main + 3073
20 libc.so.6 0x00007670c542a1ca
21 libc.so.6 0x00007670c542a28b __libc_start_main + 139
22 cling     0x00005c22074ad2e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions