Joh*_*ohn 1 c++ memory-management segmentation-fault
我正在使用一些外部C库的C ++程序上工作。据我所知,这不是问题的原因,而问题出在我的C ++代码上。该程序运行良好,没有错误,也没有测试数据集上的任何内容,但是经过几乎整个完整数据集后,出现了段错误。运行GDB给了我这个段错误:
(gdb)运行-speciesMain = allMis1 -speciesOther = anoCar2 -speciesMain = allMis1 -speciesOther = anoCar2 /hive/data/genomes/allMis1/bed/lastz.anoCar2/mafRBestNet/*.maf.gz 启动程序:/ cluster / home / jstjohn / bin / mafPairwiseSyntenyDecay -speciesMain = allMis1 -speciesOther = anoCar2 -speciesMain = allMis1 -speciesOther = anoCar2 / hive / data / genome s / allMis1 / bed / lastz.anoCar2 / mafRBestNet / *。maf.gz 从子进程3718中叉后拆卸。 程序收到信号SIGSEGV,分段故障。 来自/usr/lib64/libstdc++.so.6的__gnu_cxx :: __ exchange_and_add(int volatile *,int)()中的0x0000003009cb7672 (gdb)向上 /usr/lib64/libstdc++.so.6中的std :: basic_string,std :: allocator> ::〜basic_string()()中的#1 0x0000003009c9db59 (gdb)向上 在mafPairwiseSyntenyDecay.cpp中的#2 0x00000000004051e7在PairAlnInfo :: ~~ PairAlnInfo(this = 0x7fffffffcd70,__in_chrg =)中 (gdb)向上 #3 0x0000000000404eb0在main(argc = 2,argv = 0x7fffffffcf78)在mafPairwiseSyntenyDecay.cpp:260
好像我的PairAlnInfo类没有空了。奇怪的是,我没有定义析构函数,也没有使用分配任何东西new。我已经在Linux机器上使用g ++ 44和g ++ 4.1.2进行了尝试,并且得到了相同的结果。
使事情变得更奇怪的是,在我的linux机器上(具有更多可用的RAM和所有东西,不是该程序有问题的RAM,但这是一个强大的系统)在程序到达循环打印之前,如上所述发生了段错误输出。在使用或者G ++或铛++,程序仍然段错误,但它不会做我小很多的MacBook Air直到之后的结果打印,最后的前右侧return(0)的主要功能了。这是使用Mac的默认g ++ 4.2进行编译后,在同一个文件上运行的我的Mac上的GDB跟踪结果:
(更多结果)... 98000 27527 162181 0.83027 99000 27457 161467 0.829953 100000 27411 160794 0.829527 程序收到信号EXC_BAD_ACCESS,无法访问内存。 原因:KERN_INVALID_ADDRESS地址:0x00004a2c00106077 0x00007fff9365a6e5在std :: string :: _ Rep :: _ M_dispose()中 (gdb)向上 #1 0x00007fff9365a740 in std :: basic_string,std :: allocator> ::〜basic_string() (gdb)向上 #2 0x0000000100003938在mafPairwiseSyntenyDecay.cpp:301的main(argc = 1261,argv = 0x851d5fbff533)中 (gdb)
以防万一您没注意到我发帖的时间,现在是大约2:30 AM ...我已经为这个问题解决了大约10个小时。非常感谢您抽出宝贵的时间研究此问题并为我提供帮助!代码和复制我的情况的一些说明如下。
如果您有兴趣下载并安装带有依赖项的整个程序,请make在基本目录中下载我的KentLib存储库,然后转到examples/mafPairwiseSyntenyDecay并在make其中运行。导致我正在讨论的错误的一个示例(相当大)是此处提供的gziped文件:程序崩溃的100Mb文件。然后使用这些参数执行程序-speciesMain=allMis1 -speciesOther=anoCar2 anoCar2.allMis1.rbest.maf.gz。
(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