Open
Description
- Checked for duplicates
Describe the bug
Doing something like:
int x = 10;
x == 10;
.undo 2
float x = 10;
Works fine, but if you want to evaluate x == 10
(so no trailing colon):
int x = 10;
x == 10
.undo 2
float x = 10;
then you get a crash:
#0 0x0000000000cdc1c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/apm/clones/cling/build/install/bin/cling+0xcdc1c8)
#1 0x0000000000cd9c8e SignalHandler(int) Signals.cpp:0:0
#2 0x00007f969843f190 __restore_rt (/lib64/libc.so.6+0x3f190)
#3 0x0000000002d0b0db clang::BaseUsingDecl::removeShadowDecl(clang::UsingShadowDecl*) (/home/apm/clones/cling/build/install/bin/cling+0x2d0b0db)
#4 0x0000000000b8dfa7 clang::declvisitor::Base<std::add_pointer, cling::DeclUnloader, bool>::Visit(clang::Decl*) (/home/apm/clones/cling/build/install/bin/cling+0xb8dfa7)
#5 0x0000000000b8e210 cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) (/home/apm/clones/cling/build/install/bin/cling+0xb8e210)
#6 0x0000000000b8e322 cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*, bool) (/home/apm/clones/cling/build/install/bin/cling+0xb8e322)
#7 0x0000000000b8e210 cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) (/home/apm/clones/cling/build/install/bin/cling+0xb8e210)
#8 0x0000000000b8f6fd cling::DeclUnloader::VisitRecordDecl(clang::RecordDecl*) (.part.0) DeclUnloader.cpp:0:0
#9 0x0000000000b8fa25 cling::DeclUnloader::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) (/home/apm/clones/cling/build/install/bin/cling+0xb8fa25)
#10 0x0000000000c120e5 cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) (/home/apm/clones/cling/build/install/bin/cling+0xc120e5)
#11 0x0000000000c125f2 cling::TransactionUnloader::RevertTransaction(cling::Transaction*) (/home/apm/clones/cling/build/install/bin/cling+0xc125f2)
#12 0x0000000000be8c58 cling::Interpreter::unload(cling::Transaction&) (/home/apm/clones/cling/build/install/bin/cling+0xbe8c58)
#13 0x0000000000be8dec cling::Interpreter::unload(unsigned int) (/home/apm/clones/cling/build/install/bin/cling+0xbe8dec)
#14 0x0000000000c3561c cling::MetaSema::actOnUndoCommand(unsigned int) (/home/apm/clones/cling/build/install/bin/cling+0xc3561c)
#15 0x0000000000c31c3e cling::MetaParser::isundoCommand() (/home/apm/clones/cling/build/install/bin/cling+0xc31c3e)
#16 0x0000000000c323e9 cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (/home/apm/clones/cling/build/install/bin/cling+0xc323e9)
#17 0x0000000000c32f10 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (/home/apm/clones/cling/build/install/bin/cling+0xc32f10)
#18 0x0000000000cfa836 cling::UserInterface::runInteractively(bool) (/home/apm/clones/cling/build/install/bin/cling+0xcfa836)
#19 0x0000000000a5d44d main (/home/apm/clones/cling/build/install/bin/cling+0xa5d44d)
#20 0x00007f96984281b0 __libc_start_call_main (/lib64/libc.so.6+0x281b0)
#21 0x00007f9698428279 __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x28279)
#22 0x0000000000b014a5 _start /home/abuild/rpmbuild/BUILD/glibc-2.38/csu/../sysdeps/x86_64/start.S:117:0
If you insert a ;
after your evaluation, then it still doesn't work:
int x = 10;
x == 10
;
.undo 2
float x = 10;
(same crash, but you can .undo 1
!)
Expected behavior
I would expect to be able to "undo" evaluations.
To Reproduce
- Build
cling
- Input something like:
int x = 10;
x == 10
.undo 2
float x = 10;
- Observe crash
Setup
Machine:
% uname -a
Linux vistrrdslin0006 6.7.1-1-default #1 SMP PREEMPT_DYNAMIC Sat Jan 20 15:39:39 UTC 2024 (4959dd8) x86_64 x86_64 x86_64 GNU/Linux
lsb-release -a
LSB Version: core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0.fake-amd64:desktop-4.0.fake-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0.fake-amd64:graphics-4.0.fake-noarch
Distributor ID: openSUSE
Description: openSUSE Tumbleweed
Release: 20240124
Codename: n/a
% ldd --version
ldd (GNU libc) 2.38
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
gcc --version
gcc (SUSE Linux) 10.5.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- LLVM version (https://github.com/root-project/llvm-project.git): 3253e7800 == cling-llvm16
- Cling version (https://github.com/root-project/cling.git): aa6d492