Segmentation fault

Discussion in 'C++' started by Michael Sgier, Sep 15, 2005.

  1. Hello
    i get the error:
    Segmentation fault. The debugger stopped
    at the last of the following lines:


    // This stores the texture array for each of the textures assigned
    to this model
    unsigned int m_Textures[MAX_TEXTURES];

    // This stores a list of all the names of the textures that have
    been loaded.
    // This was created so that we could check to see if a texture that
    is assigned
    // to a mesh has already been loaded. If so, then we don't need to
    load it again
    // and we can assign the textureID to the same textureID as the
    first loaded texture.
    // You could get rid of this variable by doing something tricky in
    the texture loading
    // function, but I didn't want to make it too confusing to load the
    textures.
    std::vector<std::string> strTextures;


    I don't understand the above. Could this mess up with my imagefunction:
    img = SDL_LoadBMP(filename);??
    also the following: gluBuild2DMipmaps in the same function returns a
    memory access fault if i don't
    comment that.
    THANKS and regards
    Michael
    Michael Sgier, Sep 15, 2005
    #1
    1. Advertising

  2. Michael Sgier wrote:
    > Hello
    > i get the error:
    > Segmentation fault. The debugger stopped
    > at the last of the following lines:
    >
    >
    > // This stores the texture array for each of the textures assigned
    > to this model
    > unsigned int m_Textures[MAX_TEXTURES];
    >
    > // This stores a list of all the names of the textures that have
    > been loaded.
    > // This was created so that we could check to see if a texture that
    > is assigned
    > // to a mesh has already been loaded. If so, then we don't need to
    > load it again
    > // and we can assign the textureID to the same textureID as the
    > first loaded texture.
    > // You could get rid of this variable by doing something tricky in
    > the texture loading
    > // function, but I didn't want to make it too confusing to load the
    > textures.
    > std::vector<std::string> strTextures;
    >
    >
    > I don't understand the above. Could this mess up with my imagefunction:
    > img = SDL_LoadBMP(filename);??
    > also the following: gluBuild2DMipmaps in the same function returns a
    > memory access fault if i don't
    > comment that.
    > THANKS and regards
    > Michael


    It sounds like you've corrupted the heap. The two lines you quoted are
    perfectly fine, they are not the problem. The problem could be in any of
    the code before those two lines.

    I could be you imagefunction that is messing up, I wouldn't mind betting
    on it, but who can say for certain.

    The point is though that you've got to find where the real problem is.
    It isn't in those two lines and if you remove them the same segmentation
    fault will just appear somewhere else. Somewhere in your code you are
    trashing your computer memory and you've got to track that down and fix
    that. This is difficult enough for an experienced programmer to do let
    alone a newbie, so I suggest that you show your code to someone who is
    expereinced at C++. Otherwise you could be trying to fix this for a long
    time.

    john
    John Harrison, Sep 15, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    17
    Views:
    862
  2. Pud
    Replies:
    0
    Views:
    572
  3. Replies:
    0
    Views:
    525
  4. Ivan Vecerina
    Replies:
    0
    Views:
    482
    Ivan Vecerina
    Jun 29, 2003
  5. Vasileios Zografos

    Re: segmentation fault exception handling

    Vasileios Zografos, Jun 30, 2003, in forum: C++
    Replies:
    5
    Views:
    15,588
    Pete Becker
    Jul 1, 2003
Loading...

Share This Page