Previous How to get all the value of nbElement |
Parent How to use the debugger |
Outline |
The first hint we have is :
*** Error in `XXX/build/hadamard_product': double free or corruption (!prev): 0x0000000000615030 ***That means we wrote too much values in a table and we overflow the size of this pointer.
We also know, the bug hapens at teh very first call of the function evaluateHadamardProduct, thank to the value of nbElement :
(gdb) print nbElement $1 = 1000And finally, the bug is caused by the line 54 of our main.cpp program. This implies, the mistakes takes place before this line.
The coded line before is the line 51, with :
1 |
cout << "tabResult[0] = " << tabResult[0] << endl; |
The coded line before is the line 49, with :
1 |
hadamard_product(tabResult, tabX, tabY, 4000lu);
|
So this line must be changed into :
1 |
hadamard_product(tabResult, tabX, tabY, nbElement); |
1 2 3 4 5 |
make Scanning dependencies of target hadamard_product [ 50%] Building CXX object CMakeFiles/hadamard_product.dir/main.cpp.o [100%] Linking CXX executable hadamard_product [100%] Built target hadamard_product |
1 2 3 4 5 6 7 |
./hadamard_product Hadamard product tabResult[0] = 0 tabResult[0] = 0 tabResult[0] = 0 tabResult[0] = 0 tabResult[0] = 0 |
Do not forget to change the compilation options if you want to keep optimisation and to have a fast execution (without trouble this time).
1 |
add_definitions(-O3)
|
Previous How to get all the value of nbElement |
Parent How to use the debugger |
Outline |