c++;seg故障问题 我正在使用一个C++程序,使用一些外部C库。据我所知,这不是问题的原因,问题是我的C++代码。该程序运行良好,在我的测试数据集上没有任何错误或任何东西,但在检查了几乎整个数据集之后,我得到了一个segfault。运行GDB会给我这个错误: (gdb) run -speciesMain=allMis1 -speciesOther=anoCar2 -speciesMain=allMis1 -speciesOther=anoCar2 /hive/data/genomes/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz Starting program: /cluster/home/jstjohn/bin/mafPairwiseSyntenyDecay -speciesMain=allMis1 -speciesOther=anoCar2 -speciesMain=allMis1 -speciesOther=anoCar2 /hive/data/genome s/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz Detaching after fork from child process 3718. Program received signal SIGSEGV, Segmentation fault. 0x0000003009cb7672 in __gnu_cxx::__exchange_and_add(int volatile*, int) () from /usr/lib64/libstdc++.so.6 (gdb) up #1 0x0000003009c9db59 in std::basic_string, std::allocator >::~basic_string() () from /usr/lib64/libstdc++.so.6 (gdb) up #2 0x00000000004051e7 in PairAlnInfo::~PairAlnInfo (this=0x7fffffffcd70, __in_chrg=) at mafPairwiseSyntenyDecay.cpp:37 (gdb) up #3 0x0000000000404eb0 in main (argc=2, argv=0x7fffffffcf78) at mafPairwiseSyntenyDecay.cpp:260

c++;seg故障问题 我正在使用一个C++程序,使用一些外部C库。据我所知,这不是问题的原因,问题是我的C++代码。该程序运行良好,在我的测试数据集上没有任何错误或任何东西,但在检查了几乎整个数据集之后,我得到了一个segfault。运行GDB会给我这个错误: (gdb) run -speciesMain=allMis1 -speciesOther=anoCar2 -speciesMain=allMis1 -speciesOther=anoCar2 /hive/data/genomes/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz Starting program: /cluster/home/jstjohn/bin/mafPairwiseSyntenyDecay -speciesMain=allMis1 -speciesOther=anoCar2 -speciesMain=allMis1 -speciesOther=anoCar2 /hive/data/genome s/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz Detaching after fork from child process 3718. Program received signal SIGSEGV, Segmentation fault. 0x0000003009cb7672 in __gnu_cxx::__exchange_and_add(int volatile*, int) () from /usr/lib64/libstdc++.so.6 (gdb) up #1 0x0000003009c9db59 in std::basic_string, std::allocator >::~basic_string() () from /usr/lib64/libstdc++.so.6 (gdb) up #2 0x00000000004051e7 in PairAlnInfo::~PairAlnInfo (this=0x7fffffffcd70, __in_chrg=) at mafPairwiseSyntenyDecay.cpp:37 (gdb) up #3 0x0000000000404eb0 in main (argc=2, argv=0x7fffffffcf78) at mafPairwiseSyntenyDecay.cpp:260,c++,memory-management,segmentation-fault,C++,Memory Management,Segmentation Fault,万一你没注意到我发帖的时间,现在大约是凌晨2:30。。。我已经花了大约10个小时研究这个问题了。非常感谢您抽出时间来看看这个并帮助我!下面是复制我的情况的代码和一些说明 如果您对下载和安装带有依赖项的整个内容感兴趣,请下载我的KentLib存储库,make位于基本目录中,然后转到examples/mafPairwiseSyntenyDecay并在那里运行make。导致我正在讨论的bug的一个示例(相当大)是这里提供的gzip文件:。然后使用这些参数执行程序 /** *马夫成对综合征 *作者:约翰

万一你没注意到我发帖的时间,现在大约是凌晨2:30。。。我已经花了大约10个小时研究这个问题了。非常感谢您抽出时间来看看这个并帮助我!下面是复制我的情况的代码和一些说明

如果您对下载和安装带有依赖项的整个内容感兴趣,请下载我的KentLib存储库,
make
位于基本目录中,然后转到
examples/mafPairwiseSyntenyDecay
并在那里运行
make
。导致我正在讨论的bug的一个示例(相当大)是这里提供的gzip文件:。然后使用这些参数执行程序

/**
*马夫成对综合征
*作者:约翰圣约翰
*日期:2012年4月26日
*  
*计算不同范围容器中的平均共线衰减
*
*
*/
//肯特源C进口
外部“C”{
#包括“common.h”
#包括“options.h”
#包括“maf.h”
}
#包括
#包括
#包括
#包括
#包括
#包括
//#定义NDEBUG
#包括
使用名称空间std;
/*
全局变量
*/
PairAlnInfo类{
公众:
弦对我;
int-sstart;
int-send;
int ostart;
国际货币基金组织;
炭链;
PairAlnInfo(字符串名称),
int\u启动,int\u发送,
内部启动,内部结束,
字符(U串):
oname(_oname),
sstart(_sstart),
发送(u send),,
奥斯塔特,
oend(_oend),
链(_链){}
pairalinfo():
oname(“哑巴”),
sstart(-1),
发送(-1),
ostart(-1),
结束(-1),
链(-1){}
};
向量和拆分(常量字符串和字符串、字符、向量和元素){
溪流ss(s);;
字符串项;
while(getline(ss、item、delim)){
元素推回(项目);
}
返回(elems);
}
向量拆分(常量字符串和s、字符delim){
向量元素;
返回(拆分、删除、删除);
}
#定义定义最小长度(200)
#定义DEF_MIN_分数(200)
typedef地图pairalinfobypos;
typedef-map-ChromToPairAlnInfoByPos;
ChromToPairAlnInfoByPos pairninfobyposbychrom;
无效用法()
/*解释用法和退出*/
{
勘误表(
(char*)“MafPairwiseSyntenycay--根据至少包含两种指定物种的maf排列计算成对共线衰变。\n”
“用法:\n”
“\tmafPairwiseSyntenyDecay[选项][*必需选项]文件1.maf[.gz]…\n”
“选项:\n”
“\t-help\t打印此消息。\n”
“T-MimSale= Num \最小MaF对齐得分考虑(默认值200)\n”
“T-MialnLeN= Num \最小MAF对齐块长度考虑(默认值200)\n”
“\t-speciesMain=NAME\t*maf文件中主要物种的名称(与“.”之前显示的完全相同)(必需)\n”
“\t-speciesOther=NAME\t*maf文件中其他物种的名称(与“.”之前显示的完全相同)(必需)\n”
);
}//最终用途()
静态结构选项Spec选项[]={
/*包含命令行选项的结构*/
{(char*)“帮助”,选项_STRING},
{(char*)“minScore”,选项_INT},
{(char*)“minAlnLen”,OPTION_INT},
{(char*)“speciesMain”,选项_STRING},
{(char*)“speciesOther”,选项_STRING},
{NULL,0}
}; //结束选项()
/**
*Main函数,获取成对qseq读取的文件名
*并输出三个文件。
*/
int iterateoveralignmentblocksandstoreInfo(char*fileName、const int minScore、const int minAlnLen、const string speciesMain、const string speciesOther){
结构mafFile*mFile=mafOpen(文件名);
mafAli结构*马里;
//环行对齐块
while((mAli=mafenext(mFile))!=NULL){
结构mafComp*first=mAli->components;
int seqlen=mAli->textSize;
//首先在此块中查找并存储一组重复项
集看到;
设置DUP;
如果(马里->得分next){
字符串tmp(项目->src);
字符串tname=split(tmp,'.')[0];
如果(见计数(tname)){
//看到这个项目了吗
重复插入(tname);
}否则{
见。插入(tname);
}
}
对于(结构mafComp*item1=first;item1->next!=NULL;item1=item1->next){
//在结束前停止一个
字符串tmp1(项目1->src);
向量名称PLIT1(分裂(tmp1’,);
字符串名称1(nameSplit1[0]);
if(dups.count(name1)| |(name1!=speciesMain&&name1!=speciesOther)){
继续;
}
对于(结构mafComp*item2=item1->next;item2!=NULL;item2=item2->next){
字符串tmp2(项目2->src);
向量名称PLIT2(分裂(tmp2’,);
字符串name2=nameSplit2[0];
if(dups.count(name2)| |(name2!=speciesMain&&name2!=speciesOther)){
继续;
}
字符串chr1(nameSplit1[1]);
字符串chr2(nameSplit2[1]);
炭链;
如果(项目1->串==项目2->串)
链='+';
其他的
链='-';
int start1,end1,start2,end2;
如果(item1->strand=='+'){
start1=项目1->start;
end1=start1+item1->尺寸;
}否则{
end1=项目1->开始;
start1=end1-item1->size;
}
如果(item2->strand=='+'){
start2=项目2->start;
end2=开始2+item2->size;
}否则{
end2=项目2->开始;
开始2=结束2-项目2->大小;
}
if(name1==speciesMain){
PairAlnInfo aln(chr2,start1,end1,start2,end2,绞线);
pairalinfobyposbychrom[chr1][start1
(more results)...
98000   27527   162181  0.83027
99000   27457   161467  0.829953
100000  27411   160794  0.829527

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00004a2c00106077
0x00007fff9365a6e5 in std::string::_Rep::_M_dispose ()
(gdb) up
#1  0x00007fff9365a740 in std::basic_string, std::allocator >::~basic_string ()
(gdb) up
#2  0x0000000100003938 in main (argc=1261, argv=0x851d5fbff533) at mafPairwiseSyntenyDecay.cpp:301
(gdb)
 for(int k = numBucketsThisWindow; k<numDiscontigBuckets && k < blockSize; k++){