Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: glDeleteTextures() throws "An invalid HANDLE was specified"-exception C0000008

  1. #1
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167

    glDeleteTextures() throws "An invalid HANDLE was specified"-exception C0000008

    Hello!
    I'm kinda ashamed to ask this question, but:
    In one of my projects, during the cleanup-routine, glDeleteTextures() throws the exception mentioned above IF running it from within Visual Studio - that is no glError is generated nor does the program crash or something if run outside the IDE. If simply clicking "continue" everything seems to go well. Note the above is a windows-exception, not a glError.
    I've spent some time trying to reproduce it in test-cases but this does not seem so easy. Even when calling DeleteTextures with trash-values nothing special happens. The strange thing is that quite a few textures get deleted during the cleanup and only one or two trigger that exception, so I doubt I'm doing something wrong methodically. I've tried to verify the texture-ids passed to glDeleteTextures: I've checked for double-ids and I even drew each texture in full-screen before calling the cleanup-routine to have a look if the ids are okay: They are all there.
    I've to say I don't have the slightest idea what could trigger the exception.
    Does anyone have an idea?

    Thanks in advance,
    HL

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    Just for information: The problem disappeared. Not that I did change anything that should have solved this...
    This somehow leaves a bad taste.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,212
    Do you delete textures before or after destroying your window?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    Before as destroying the window would destroy the rendering-context the textures live in I guess. The exception popped up once or twice again since it seemed to be gone. This is quite mysterious. Note that I did come to writing a cleanup routine because of the very same exception being thrown by the driver when simply calling exit() or destroying the rendering context without deleting anything myself. My guess was the OS would handle the cleanup correctly (and it did, I guess - the exception doesn't do anything outside the IDE).

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,212
    Quote Originally Posted by hlewin View Post
    The exception popped up once or twice again since it seemed to be gone.
    Sounds like you've a wild pointer then.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    Dunno - what do you mean? Is it possible that the DeleteTextures-call triggers something else that leads to the exception (like the driver shifting around stuff because some mem got freed)? The exception appears in the controlled cleanup-Routine. This is what is making me scratching my head.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,212
    Quote Originally Posted by hlewin View Post
    Is it possible that the DeleteTextures-call triggers something else that leads to the exception.
    Unlikely.

    HANDLE in this exception is a Windows API data type, and the fact that the exception is being thrown with seeming randomness indicates that the problem is not at the glDeleteTextures call but somewhere else. One thing that can cause this is a bad pointer leading to a corrupted return address leading to execution jumping into the middle of a function where it has no business being.

    Have you tried running this in a debugger?

  8. #8
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    No, that beast was thrown somewhere deep in nvogl. Seemed all right. Doesn't even do anything except open up the exception handler built into the IDE.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,212
    Breakpoint before the glDeleteTextures call, breakpoint after it, inspect variables, including your HDC, your HGLRC and the texture name to be deleted.

  10. #10
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    That won't lead anywhere I guess. Despite the fact that it would likely take 10000 "continue"-clicks to catch the exception, now that it suddenly seems to have fixed itself. No - those pointers are all right. If something was wrong context-wise I'd have catched that later on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •