#71755 - ishraam - Tue Feb 14, 2006 7:15 am
Hi,
I've just had a strange problem : my app crashes because of a SEG FAULT caused by a "for(...)" whose max limit has been changed by... the hardware I guess (not me anyway!).
Just have a look at this (IT USES GBFS):
When curVert is equal to this->numVertices, this->numVertices value get totally f**ed up. And of course > seg fault.
I noticed that with enough "iprintf(...);" in this function, there's no problem anymore.
So I thought "damn do I need a volatile or what ?". So I tried, but no difference.
Do you have any idea of what's the problem ???
EDIT :
I've played some more with the code.
Declaring "numVertices" as an int instead of a uint32 had no effect.
BUT, after having removed all of the "iprintf(...)" that were close to GL functions, the problem disappeared.
When I say "close to GL functions", I mean any other member function like a DrawNormals() that would have a simple
would cause the same error (in the same LoadFromFile() function!!)...
Event though the problem is "gone", I still cannot understand all this.
And I definitely wanna understand, so here again :
Do you have any idea of what's the problem ???
EDIT ..AGAIN:
Daaamn!
I can't even add a member function to load a texture. It causes the same problem (and without any "iprintf(...)" around > so I guess that's not related) : the member variable "numVertices" of my "Mesh" class gets changed during the loop.
That's driving me crazy!
Last edited by ishraam on Wed Feb 15, 2006 8:48 am; edited 2 times in total
I've just had a strange problem : my app crashes because of a SEG FAULT caused by a "for(...)" whose max limit has been changed by... the hardware I guess (not me anyway!).
Just have a look at this (IT USES GBFS):
Code: |
void Mesh::LoadFromFile() { [...] for( uint32 curVert = 0; curVert < this->numVertices; curVert ++) { readstr(oneline); sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v); iprintf(" d/%d)",curVert+1,numVertices); vertices[curVert].position = AL_Vector3(x,y,z); vertices[curVert].tex = AL_TexCoord(u,v); vertices[curVert].normal = AL_Vector3(0.f,1.f,0.f); } return; } |
When curVert is equal to this->numVertices, this->numVertices value get totally f**ed up. And of course > seg fault.
I noticed that with enough "iprintf(...);" in this function, there's no problem anymore.
So I thought "damn do I need a volatile or what ?". So I tried, but no difference.
Do you have any idea of what's the problem ???
EDIT :
I've played some more with the code.
Declaring "numVertices" as an int instead of a uint32 had no effect.
BUT, after having removed all of the "iprintf(...)" that were close to GL functions, the problem disappeared.
When I say "close to GL functions", I mean any other member function like a DrawNormals() that would have a simple
Code: |
"iprintf("yo");" |
would cause the same error (in the same LoadFromFile() function!!)...
Event though the problem is "gone", I still cannot understand all this.
And I definitely wanna understand, so here again :
Do you have any idea of what's the problem ???
EDIT ..AGAIN:
Daaamn!
I can't even add a member function to load a texture. It causes the same problem (and without any "iprintf(...)" around > so I guess that's not related) : the member variable "numVertices" of my "Mesh" class gets changed during the loop.
That's driving me crazy!
Last edited by ishraam on Wed Feb 15, 2006 8:48 am; edited 2 times in total