Erreure � l'execution, invalid Pointer
Bonjour,
j'obtiens une erreur lors de l'ex�cution de mon programme que j'ai du mal � comprendre.
Code:
*** glibc detected *** /chemin/vers/executable: munmap_chunk(): invalid pointer: 0xb1e0a8b0 ***
en fait ce qui m'�tonne c'est que cet erreur ce produit juste apr�s l'appel d'une fonction1 dans une fonction2. si je fait le traitement de fonction1 directement dans fonction2 je n'ai pas l'erreur. j'ai v�rifier l'adresse de tous les �l�ments envoy�s � ma fonction en param�tre et aucune ne correspond au pointer d�sign� comme invalid.
d'ailleur voici le corp de la fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| void
FindHole(ImageType::Pointer image, ImageType::RegionType region, int direction)
{
std::cout<<"&&&&&&&&&&&&&&&&&FIND HOLE&&&&&&&&&&&&&&"<<std::endl;
std::cout<<image<<std::endl;
LinearConstIteratorType lcoit(image, region);
lcoit.SetDirection(direction);
//a vector which contains vectors for the coef slop of the intensity profile
std::vector <std::vector<float> > vect_vect_coefSlop;
//a vector which contains vectors for the position of the extrema
std::vector <std::vector<int> > vect_vect_extremaPosition;
//for each line
for (lcoit.GoToBegin(); !lcoit.IsAtEnd(); lcoit.NextLine())
{
//create vector for intensity profile, derive extrema position, and coefSlop
std::vector <unsigned short> vect_intensite;
std::vector < short> vect_derive;
std::vector <int> vect_extremaPosition;
std::vector <float> vect_coefSlop;
//for each pixel of the current line
while ( !lcoit.IsAtEndOfLine() )
{
//collect the intensity of the current pixel
vect_intensite.push_back(lcoit.Get());
++lcoit;
}
//then from the seconde to the penultimate intensity pix
for (int i=1; i<vect_intensite.size()-1; ++i)
{
//calculate derive
vect_derive.push_back(vect_intensite[i+1]-vect_intensite[i-1]);
}
//then for each derive
bool old_signe = true;
if (vect_derive[0]<0) old_signe = false;
for (int j = 1; j<vect_derive.size(); ++j)
{
bool signe;
//explore signe and update old_signe
if (vect_derive[j] < 0)
{
signe = false;
}
else
{
signe = true;
}
//if we have a change of slop signe
if (old_signe != signe )
{
vect_extremaPosition.push_back(j);
//std::cout<<"extrema position at line : "<<l<<", column : "<<j<<std::endl;
}
old_signe = signe;
}
for (int k = 1; k<vect_extremaPosition.size(); ++k)
{
int currentCol = vect_extremaPosition[k];
int oldCol = vect_extremaPosition[k-1];
float coefSlop = (vect_intensite[currentCol] - vect_intensite[oldCol])/(currentCol-oldCol+0.0) ;
vect_coefSlop.push_back(coefSlop);
//std::cout<<"coef slop : "<<coefSlop<<std::endl;
}
//hold the coefSlop and the extrema position for each lines
vect_vect_coefSlop.push_back(vect_coefSlop);
vect_vect_extremaPosition.push_back(vect_extremaPosition);
}
//for each lines
float coefSlopValue_old = 0;
int bestLine = 0;
for (int l = 0; l < vect_vect_coefSlop.size(); ++l)
{
//for each column
int count = 0;
float coefSlopValue = 0;
for (int c = 0; c <vect_vect_coefSlop[l].size(); ++c)
{
//if we have a coeficient <-20 between 2 extrema the first one is a max wich point on a hole !!
if (vect_vect_coefSlop[l][c] < -20)
{
++count;
coefSlopValue += vect_vect_coefSlop[l][c];
}
else
{
vect_vect_coefSlop[l].erase(vect_vect_coefSlop[l].begin() + c-1);
vect_vect_extremaPosition[l].erase(vect_vect_extremaPosition[l].begin() + c-1);
}
if (count == 4)
{
//std::cout<<"4 aligned hole!"<<std::endl;
coefSlopValue /= 4;
//std::cout<<"coefSlopValue : "<<coefSlopValue<<std::endl;
if (coefSlopValue < coefSlopValue_old)
{
coefSlopValue_old = coefSlopValue;
bestLine = l;
std::cout<<"best 4 aligned hole at line : "<<l<<std::endl;
}
}
}
}
std::cout<<"&&&&&&&&&&&&&&&&&FIND HOLE DONE&&&&&&&&&&&&&&"<<std::endl;
} |
image est un smartPointer de la librairie itk
(je travail avec l'EDI code::blocks et le compilateur gcc)
GDB me dit que la derni�re fonction (de mon programme) appel�e est bien FindHole.
Si vous avez une id�e, sur ce qui peut �tre la cause de ce genre d'erreurs, votre avis m'int�resse.
Bonne journ�e.
rp