I am getting the below sysmalloc error in running a C program.
malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *)
&((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd))))
&& old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)
((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))
+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1)))
&& ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
The program works fine when using an int array
int(*M)[cnt] = malloc(sizeof(int[cnt][cnt]));
but is showing the above error for signed long int. There is no other change made in the program.
signed long int(*M)[cnt] = malloc(sizeof(signed long int[cnt][cnt]));
What could be the reason? This worked perfectly when using an int array. Hence there shouldn't be a problem with memory management as given here C Malloc assertion failure
Thanks