Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7110 Discussions

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

hemantp_p_
Beginner
1,597 Views

Sir,

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

0 Kudos
1 Solution
Ying_H_Intel
Employee
1,597 Views

Hello,  

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,

Ying 

 

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

 

View solution in original post

0 Kudos
1 Reply
Ying_H_Intel
Employee
1,598 Views

Hello,  

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,

Ying 

 

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

 

0 Kudos
Reply