| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1533 人关注过本帖
标题:【求助】linux下变异没有问题,运行时出现下列信息,请教xdjm这是怎么回事? ...
取消只看楼主 加入收藏
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
结帖率:91.67%
收藏
已结贴  问题点数:4 回复次数:12 
【求助】linux下变异没有问题,运行时出现下列信息,请教xdjm这是怎么回事?
*** glibc detected *** ./sky: free(): invalid next size (fast): 0x000000000060b090 ***
======= Backtrace: =========
/lib/libc.so.6(+0x72966)[0x7fcf76bb4966]
/lib/libc.so.6(cfree+0x6c)[0x7fcf76bb971c]
./sky[0x4082ca]
./sky[0x40850e]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7fcf76b60bbd]
./sky[0x400b69]
======= Memory map: ========
00400000-0040a000 r-xp 00000000 08:11 126460221                          /rd2/user/lihengde/gmat/sky
00609000-0060a000 r--p 00009000 08:11 126460221                          /rd2/user/lihengde/gmat/sky
0060a000-0060b000 rw-p 0000a000 08:11 126460221                          /rd2/user/lihengde/gmat/sky
0060b000-0062c000 rw-p 00000000 00:00 0                                  [heap]
7fcf70000000-7fcf70021000 rw-p 00000000 00:00 0
7fcf70021000-7fcf74000000 ---p 00000000 00:00 0
7fcf7692b000-7fcf76941000 r-xp 00000000 68:03 7462927                    /lib64/libgcc_s.so.1
7fcf76941000-7fcf76b40000 ---p 00016000 68:03 7462927                    /lib64/libgcc_s.so.1
7fcf76b40000-7fcf76b41000 r--p 00015000 68:03 7462927                    /lib64/libgcc_s.so.1
7fcf76b41000-7fcf76b42000 rw-p 00016000 68:03 7462927                    /lib64/libgcc_s.so.1
7fcf76b42000-7fcf76c92000 r-xp 00000000 68:03 25142404                   /lib64/libc-2.11.2.so
7fcf76c92000-7fcf76e91000 ---p 00150000 68:03 25142404                   /lib64/libc-2.11.2.so
7fcf76e91000-7fcf76e95000 r--p 0014f000 68:03 25142404                   /lib64/libc-2.11.2.so
7fcf76e95000-7fcf76e96000 rw-p 00153000 68:03 25142404                   /lib64/libc-2.11.2.so
7fcf76e96000-7fcf76e9b000 rw-p 00000000 00:00 0
7fcf76e9b000-7fcf76f1b000 r-xp 00000000 68:03 25142116                   /lib64/libm-2.11.2.so
7fcf76f1b000-7fcf7711a000 ---p 00080000 68:03 25142116                   /lib64/libm-2.11.2.so
7fcf7711a000-7fcf7711b000 r--p 0007f000 68:03 25142116                   /lib64/libm-2.11.2.so
7fcf7711b000-7fcf7711c000 rw-p 00080000 68:03 25142116                   /lib64/libm-2.11.2.so
7fcf7711c000-7fcf7713a000 r-xp 00000000 68:03 25142422                   /lib64/ld-2.11.2.so
7fcf77314000-7fcf77317000 rw-p 00000000 00:00 0
7fcf77337000-7fcf77339000 rw-p 00000000 00:00 0
7fcf77339000-7fcf7733a000 r--p 0001d000 68:03 25142422                   /lib64/ld-2.11.2.so
7fcf7733a000-7fcf7733b000 rw-p 0001e000 68:03 25142422                   /lib64/ld-2.11.2.so
7fcf7733b000-7fcf7733c000 rw-p 00000000 00:00 0
7fffa8e0c000-7fffa8e21000 rw-p 00000000 00:00 0                          [stack]
7fffa8e6f000-7fffa8e70000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted
搜索更多相关主题的帖子: 信息 invalid Memory linux 
2011-11-18 09:43
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
我的数据量可是很小啊,就是弄个小例子试试而已。
2011-11-18 09:44
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
在windows下是没有任何问题的
2011-11-18 09:45
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
我检查了,好像没有释放两次啊,在windows下运行没有一点问题啊,奇怪了,在liunux下我如果运行 sky xx -method 44 没有问题,只有在运行 sky xx -method 55时有问题,设置了一个标志检查,哪个部分的运算能够执行。在程序里,这个部分执行后的确是释放内存,所以检测到的是free这里出问题了,可是程序里没有重复释放啊,奇怪了,也没有释放NULL指针。
2011-11-18 10:32
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
code太长,我把那个函数贴出来

/*=======================================================================================*/

/*
    Name:        gmcal
    Date:        2010-11-10
    Role:        Calculation of G matrix and its inverse
    Parameter:    the parameters in command line
*/
void gmcal(int argc, char * argv[])
{
    // define filenames
    char fg[30], fp[30], fi[30], gm[30], gi[30], gz[30], gf[30], fm[30];
    strcpy(fg, argv[1]);  strcat(fg, ".gen");
    strcpy(fp, argv[1]);  strcat(fp, ".phe");
    strcpy(fi, argv[1]);  strcat(fi, ".info");
    strcpy(gm, argv[1]);  strcat(gm, ".gmat");
    strcpy(gi, argv[1]);  strcat(gi, ".ginv");
    strcpy(gz, argv[1]);  strcat(gz, ".zmat");
    strcpy(gf, argv[1]);  strcat(gf, ".maf");
    strcpy(fm, argv[1]);  strcat(fm, ".mmat");

    // define and read or determine the integer variables
    int nobs=0, nmrk=0, nfactor, ntrait, i=0, j, m=0, nmrk2;
    int *pn, *pm, *pf, *pt;
    pn = &nobs; pm = &nmrk; pf = &nfactor; pt = &ntrait;
    nmrk2 = nmrk;
    readinfo(fi, pn, pm, pf, pt);

    if (nobs==0 || nmrk==0)
    {
        printf("ERROR: NO observations was read into program !!!\n");
        exit(1);
    }
   
    // define necessary vectors
    int    * id     = (int    *)malloc(sizeof(int)*nobs);
    int    * sire   = (int    *)malloc(sizeof(int)*nobs);
    int    * dam    = (int    *)malloc(sizeof(int)*nobs);
    int    * sex    = (int    *)malloc(sizeof(int)*nobs);
    int    * geno   = (int    *)malloc(sizeof(int)*nobs*2*nmrk);   
    int    * factor = (int    *)malloc(sizeof(int)*nfactor*nobs);
    double * trait  = (double *)malloc(sizeof(double)*nobs*ntrait);
    // read genotype and phenotype data
    readgen(fg, nobs, nmrk, geno);
    readped(fp, nobs, nfactor, ntrait, id, sire, dam, sex, factor, trait);

    free(trait);    free(factor);    free(sex);
    //    readped(fp, nobs, ntrait, id, sire, dam, sex, trait);
    // determine which method was used to calculate G matrix
    for (i=3; i<argc; i++)
    {
        if (strcmp(argv[i],"-method")==0)
            { m = atoi(argv[i+1]); }
    }

    // MAF calculation
    double * a1f = malloc(sizeof(double)*nmrk);
    alfcal(nobs, nmrk, sire, dam, geno, a1f, m, gf);

    // coding the genotype
    printf("Coding the genotype ......\n");   
    double * z2 = (double *)malloc(sizeof(double)*nmrk*nobs);
    gcodem(nobs, nmrk, geno, a1f, z2);
    free(geno);        
    writem(nobs, nmrk, z2, fm);

    int * mid = (int *)malloc(sizeof(int)*nmrk);
    mrkind(nobs, nmrk, z2, a1f, mid);
    nmrk2 = isum(mid,nmrk);
    double *af = (double *)malloc(sizeof(double)*nmrk2);
    double * z = (double *)malloc(sizeof(double)*nobs*nmrk2);
    mcut(nobs, nmrk, nmrk2, z2, z, mid, a1f, af);
    free(mid); free(z2); free(a1f);


    if (m!=31 && m!=32 && m!=91 && m!=92)
    {   
        gcodez(nobs, nmrk2, af,  z);
        writem(nobs,nmrk2, z, gz);
    }

    // calculate G matrix
    printf("Calculating G matrix ......\n");
    double * g = (double *)malloc(sizeof(double)*(nobs*(nobs+1)/2));   
    gmat(nobs, nmrk2, af, z, g, m, id, sire, dam);

    // write the G matrix (lower triangular) to a file
    writeg(nobs, g, gm);
    /*运行到这里是没有任何问题的*/
    free(id);    free(sire);    free(dam);    free(z);    free(af);
   
    // invert G matrix   
    printf("Inverting G matrix ......\n");

    /*
       to ensure inverting g matrix, the diagonal elements were added 0.001,
        this trick can be seen in Meuwissen et al. 2011.
    */
    for (j=0; j<nobs; j++)
    {
        i = (j+1)*(j+2)/2 -1;
        g[i]=g[i]+0.001;
    }
    i=ssgj(g,nobs);

    // write the inverse of G matrix to a file
    if (i>0)    writegi(nobs, g, gi);
       free(g);
    return;
}

/*=======================================================================================*/
2011-11-18 10:46
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
为了检查空指针问题,我在linux下编译运行如下代码都没有问题
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
        int * i = malloc(sizeof(int)*0);
        int * j = malloc(sizeof(int)*9);
        free(i);
        free(j);
        printf("OK\n");
        return 0;
}
所以感觉到奇怪
2011-11-18 10:48
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
大侠,请查收
2011-11-18 11:09
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
怎么了?
2011-11-18 13:01
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
我的确没有做过项目,也没有make file,我在linux下用gcc编译,就是直接用 gcc sky_v3.c -o sky -lm 就可以了
2011-11-18 13:19
hengde_li
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:131
专家分:178
注 册:2010-1-15
收藏
得分:0 
是啊,真奇怪,如果运行其他选择就没有问题,运行5x就有问题,指针释放也没有什么问题啊。怪了。
2011-11-18 14:17
快速回复:【求助】linux下变异没有问题,运行时出现下列信息,请教xdjm这是怎么 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035594 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved