*** glibc detected *** ./test.out: free(): invalid next size (fast)

*** glibc detected *** ./test.out: free(): invalid next size (fast)


i am trying to multiply 2 block sparse matrices ie. block elemnts along the diagnol. in my case two 4*4 blocks.

a_mat is the nonzero array for A. since A is 8*8 a_mat(columns array as per documentation) is 8*4 due to block diagnol sparsenes.

the result is atored in either q_mat or b_mat.

i have tried bot routines mkl_scsrmultd(a_mat * a_mat) & scsrmm(a_mat *b_mat)

also i have seen to that scscrmult gets one based indexing and scsrmm get zero based. I just cant seem to figure out the error as to which size is wrong .


Please help

Downloadtext/x-csrc test1.c1.79 KB
Downloadtext/x-chdr gen_col.h592 bytes
Downloadtext/plain cmd.txt499 bytes
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply


It seems your code have some memory issues. If you have  Intel Inspector XE, you will find the problem in quick way :). 

The main problem are in the *.h file. They should be : malloc(M*N*sizeof(int))

int * gen_col(int M, int N)
    int n = 0;
        int m = 0;
        int k = 1;
        int i;
    int *x = (int*)malloc(M*N*sizeof(int));


void * gen_row(int M, int N)
    int i;
    int *x = (int*)malloc((M+1)*sizeof(int));


and other memory leak as you only malloc them, but haven't free them. 

Best Regards,



Inspector result :)

ID        Type    Sources    Modules    Object Size    State

P1        Unhandled application exception    read.c    MSVCR100D.dll        New
P2        Memory leak    gen_col.h    mkl-lab1-dgemm.exe    32    New
P3        Memory leak    test1.cpp    mkl-lab1-dgemm.exe    128    New
P4        Memory leak    test1.cpp    mkl-lab1-dgemm.exe    256    New
P5        Memory leak    test1.cpp    mkl-lab1-dgemm.exe    256    New
P6        Invalid memory access    gen_col.h    mkl-lab1-dgemm.exe        New
P7        Invalid memory access    test1.cpp    mkl-lab1-dgemm.exe        New


Leave a Comment

Please sign in to add a comment. Not a member? Join today