Unhandled exception: User breakpoint

This is a discussion on Unhandled exception: User breakpoint within the C++ Programming forums, part of the General Programming Boards category; Hi, If I run the .exe of a program I made it gives the usual message box "program x has ...

  1. #1
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345

    Unhappy Unhandled exception: User breakpoint

    Hi,

    If I run the .exe of a program I made it gives the usual message box "program x has encountered a problem ... "
    However, when I run VC++.NET debugger to find out what's wrong, it just works! And then, when I close the program I get
    Code:
    "Unhandled exception at 0x77f7f570 in x.exe: User breakpoint."
    and the debugger breaks to free.c

    I guess I'm doing something that causes access violation, which is, for some reason, isn't detected by the debugger, and then when I shut down, some destructor calling delete causes the above error message.

    My questions:

    1. is the above error message really caused by deleting some memory not allocated by new (or free)?

    2. Why isn't the first error message detected by the debugger?

    3. how am I supposed to debug this if the debugger doesn't detect it (is there a better way to do debugging)?

    thanks in advance.

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Post your code.

    I think I may know where this problem lies. Often, you can accidentally muck around with memory that isn't yours. When it comes time to close the program, it has a bit of trouble and throws a wobbly. But really, I couldn't say for sure unless I had THE CODE in front of me.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    In addition, what does the call stack say when the error occurs? If you look up (or down I guess) the call stack, you should be able to see what part of your code is being destroyed that is calling free. That would help you narrow down which memory might be getting overwritten, or if an object is being deleted twice, etc.

    Also, I don't know if you use exceptions, but sometimes it is helpful to change all of your Exception settings to "stop always". If an exception or access violation occurs in the middle of the program, it will break execution and you can look into your call stack and see exactly where in your code it occurred.

  4. #4
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    thank you guys sooo much, this call satck thingy is exactly what I needed, I wasn't aware of it before btw
    it turned out that I forgot to overload = operator in one of my classes, which contained a pointer to the beginning of an array, when I used = to copy an instance fields to another's, I was actually copying a memory address instead of data, later when the program exits, the destructor is called, deleting one instance and leaving the other instance field pointing to memory which isn't mine any more
    I just overloaded the = operator to copy data instead of addresses, I don't see that dreaded error message any more
    thanks again.

    PS: as for posting the code, it's not just one small file to post, and I didn't know where that error was actually happening, all what I got was free.c, now with call stack I can locate errors in no time.

    I've got another problem to fix, I'll try on my own, if I can't manage to fix it, I'll create a new thread, but any way, does anybody know why glTexParameteri causes access violation? it's called exactly after gluBuild2DMipmaps, I guess it has something to do with my image loading code, it only happens with some images not all of them, JPG images, I noticed that it happens with none 2^i x 2^j images.
    I'll try to fix it, otherwise I'll post in the game programming forum.

    ^^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unhandled exception
    By JOCAAN in forum C Programming
    Replies: 5
    Last Post: 11-30-2008, 09:18 AM
  2. Debugging and unhandled exception
    By Overlord in forum Windows Programming
    Replies: 2
    Last Post: 07-25-2008, 06:39 AM
  3. I got an unhandled exception!!
    By LegendBreath in forum Game Programming
    Replies: 7
    Last Post: 04-19-2005, 01:55 PM
  4. Unhandled Exception (Vectors)
    By wbeasl in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2004, 07:36 AM
  5. unhandled exception (URGENT)
    By Lollipop in forum C++ Programming
    Replies: 8
    Last Post: 08-06-2003, 10:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21