根:违反细分

问题描述

我正在Ubuntu 18.04上运行Cern ROOT 6.22 / 00。我正在运行一个非常简单的代码,该代码可以读取数据并绘制图形。

// filename.C Example of graph with SetPoint

{
    g = new TGraph();
    
    for(i=0; i<10; i++) {
        g->SetPoint(i,i,i*i - 4*i + 7);
    }
    
    g->SetMarkerStyle(22);
    g->Draw("ALP");
}

当我继续并使用.x filename.C执行代码时,代码将按预期工作。但是,当我再次运行同一命令时,出现了细分错误

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f7c2e7166e7 in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f7c2e681107 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007f7c2f2b8ed3 in TUnixSystem::StackTrace() () from /home/nick/root/lib/libCore.so.6.22
#3  0x00007f7c2f2bb9c5 in TUnixSystem::dispatchSignals(ESignals) () from /home/nick/root/lib/libCore.so.6.22
#4  <signal handler called>
#5  0x00007f7c29f24393 in (anonymous namespace)::ScalarExprEmitter::EmitScalarConversion(llvm::Value*,clang::QualType,clang::SourceLocation,bool) () from /home/nick/root/lib/libCling.so
#6  0x00007f7c29f25e84 in clang::CodeGen::CodeGenFunction::EmitScalarConversion(llvm::Value*,clang::SourceLocation) () from /home/nick/root/lib/libCling.so
#7  0x00007f7c29eed6e0 in clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) () from /home/nick/root/lib/libCling.so
#8  0x00007f7c29d70dc3 in clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&,llvm::ArrayRef<clang::Attr const*>) () from /home/nick/root/lib/libCling.so
#9  0x00007f7c29d6f305 in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) () from /home/nick/root/lib/libCling.so
#10 0x00007f7c29d6f42f in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&,bool,clang::CodeGen::AggValueSlot) () from /home/nick/root/lib/libCling.so
#11 0x00007f7c29daab12 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,llvm::Function*,clang::CodeGen::CGFunctionInfo const&) () from /home/nick/root/lib/libCling.so
#12 0x00007f7c29dc8098 in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDeFinition(clang::GlobalDecl,llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#13 0x00007f7c29dea828 in clang::CodeGen::CodeGenModule::EmitGlobalDeFinition(clang::GlobalDecl,llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#14 0x00007f7c29debb05 in clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) () from /home/nick/root/lib/libCling.so
#15 0x00007f7c29dec46f in clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) () from /home/nick/root/lib/libCling.so
#16 0x00007f7c29d2edfd in clang::CodeGeneratorImpl::HandletopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#17 0x00007f7c2a07aba0 in clang::MultiplexConsumer::HandletopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#18 0x00007f7c29ca5aea in cling::DeclCollector::HandletopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#19 0x00007f7c29c72bec in cling::IncrementalParser::ParseInternal(llvm::StringRef) () from /home/nick/root/lib/libCling.so
#20 0x00007f7c29c7540c in cling::IncrementalParser::Compile(llvm::StringRef,cling::Compilationoptions const&) () from /home/nick/root/lib/libCling.so
#21 0x00007f7c29bf36ad in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char> > const&,cling::Compilationoptions,cling::Value*,cling::Transaction**,unsigned long) () from /home/nick/root/lib/libCling.so
#22 0x00007f7c29bf3aaa in cling::Interpreter::process(std::__cxx11::basic_string<char,bool) () from /home/nick/root/lib/libCling.so
#23 0x00007f7c29cb50df in cling::MetaProcessor::readInputFromFile(llvm::StringRef,unsigned long,bool) () from /home/nick/root/lib/libCling.so
#24 0x00007f7c29b6e004 in TCling::ProcessLine(char const*,TInterpreter::EErrorCode*) () from /home/nick/root/lib/libCling.so
#25 0x00007f7c29b6eaa2 in TCling::ProcessLinesynch(char const*,TInterpreter::EErrorCode*) () from /home/nick/root/lib/libCling.so
#26 0x00007f7c2f15cba8 in TApplication::ExecuteFile(char const*,int*,bool) () from /home/nick/root/lib/libCore.so.6.22
#27 0x00007f7c2f15c3d0 in TApplication::ProcessLine(char const*,int*) () from /home/nick/root/lib/libCore.so.6.22
#28 0x00007f7c2f6d9002 in TRint::ProcessLineNr(char const*,char const*,int*) () from /home/nick/root/lib/libRint.so.6.22
#29 0x00007f7c2f6d93f4 in TRint::HandleTerminput() () from /home/nick/root/lib/libRint.so.6.22
#30 0x00007f7c2f2bacb0 in TUnixSystem::CheckDescriptors() () from /home/nick/root/lib/libCore.so.6.22
#31 0x00007f7c2f2bc668 in TUnixSystem::dispatchOneEvent(bool) () from /home/nick/root/lib/libCore.so.6.22
#32 0x00007f7c2f1c7751 in TSystem::Run() () from /home/nick/root/lib/libCore.so.6.22
#33 0x00007f7c2f159e7f in TApplication::Run(bool) () from /home/nick/root/lib/libCore.so.6.22
#34 0x00007f7c2f6da9f1 in TRint::Run(bool) () from /home/nick/root/lib/libRint.so.6.22
#35 0x000055f5d5017a3c in main ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007f7c29f24393 in (anonymous namespace)::ScalarExprEmitter::EmitScalarConversion(llvm::Value*,bool) () from /home/nick/root/lib/libCling.so
===========================================================

我确定这与我的代码本身无关,但是有解决此问题的想法吗?

解决方法

我在ROOT 6.20 / 06上尝试了您的代码,但确实由于与您发布的相同的细分错误而崩溃,但是我可以通过声明变量g和i的类型来简单地运行您的代码:

{
  TGraph* g = new TGraph();
  for(int i=0; i<10; i++) {
    g->SetPoint(i,i,i*i - 4*i + 7);
  }
  g->SetMarkerStyle(22);
  g->Draw("ALP");
}

TGraph :: SetPoint方法本身可以处理内存分配问题,因此代码原则上没有问题,只需要在C / C ++中声明变量时要小心。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...