free(): invalid next size (fast) / free(): invalid pointer Program received signal SIGABRT: Process abort signal

100 Views Asked by At

Program works fine for every number except 5, 9, 13, 17, 21, 25, ... (4*n)+1 (for n > 0)
When entering 5 as the first number for the calculation, the failure is "free(): invalid next size (fast)" .

The code is allocateing two 1-dim. arrays to save the calculated legendre polynoms. In the end the polynoms get deallocated.

Output:


Enter the grade n of the legendre ploynom.
4
 It is  T  that iterative and recursive calculation are equal.
 Enter the grade n of the legendre ploynom.
6
 It is  T  that iterative and recursive calculation are equal.
 Enter the grade n of the legendre ploynom.
5
free(): invalid pointer

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x7fa540867bd0 in ???
#1  0x7fa540866e25 in ???
#2  0x7fa5406acd5f in ???
#3  0x7fa5406acce1 in ???
#4  0x7fa540696536 in ???
#5  0x7fa5406ee3a7 in ???
#6  0x7fa5406f5699 in ???
#7  0x7fa5406f6853 in ???
#8  0x55d4b8d74044 in __legendre_MOD_rleg
        at src/legendre.f95:186
#9  0x55d4b8d73da2 in __legendre_MOD_rleg
        at src/legendre.f95:186
#10  0x55d4b8d73da2 in __legendre_MOD_rleg
        at src/legendre.f95:186
#11  0x55d4b8d74ac4 in leg
        at src/legendre.f95:234
#12  0x55d4b8d74e91 in main
        at src/legendre.f95:221
[1]    21146 abort (core dumped)  ./myapp

I tried the identic code on another computer (windows 11) and it worked. I am using LMDE5.

The problem appears as soon as i save the calculated polynoms in the allocated arrays.

0

There are 0 best solutions below