debugging timing conflicts

This is a discussion on debugging timing conflicts within the C++ Programming forums, part of the General Programming Boards category; i have a problem...or worse, ironically, i had a problem. for the last two days, when my application opened, it's ...

  1. #1
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839

    debugging timing conflicts

    i have a problem...or worse, ironically, i had a problem.

    for the last two days, when my application opened, it's execution would simply stop. it was not caught in an infinite loop (CPU usage was 0) and no error was encountered.

    i was in the process of trying to isolate the problematic bits when, as mysteriously as it appeared, it went away. it is definitely not something i changed, because a copy of the malfunctioning code now functions also.

    i do not have a clue as to how to go about debugging something like this. any suggestions would be much appreciated.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    You could keep a log file of timings with different parts of your code, especially around system calls and other calls to external resources.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    I know just the thread for you. Debugging a rare / unreproducible bug..
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    why thank you good sir.

    i actually found the source of the problem yesterday. the malfunctioning code promptly resumed malfunctioning repeatably after i posted that, and the version i was working on still didn't. so i ran a diff on all the files in the project and sure enough, i had actually fixed it.

    i still don't understand why it was producing that behavior though. as best i can tell, the issue seems to have been that a thread was erroneously being executed in the main thread. this particular thread had an empty functor list, so it immediately suspended itself; which for some reason suspended execution of the main thread.

    i do not get it. I called the method to execute method in it's own thread, not the main thread, so why this happened is truly a mystery to me.
    Last edited by m37h0d; 07-24-2008 at 11:42 AM.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    You mean, why it sometimes crashed and sometimes didn't?

    That's the nature of memory errors. Buffer overruns, invalid pointer accesses, double frees, etc. They can be very hard to track down. Valgrind's my favourite tool for doing so, or GDB if it actually segfaults.

    Take buffer overruns, for example. Will it crash? It depends on what you're overwriting. If you're overwriting other variables in your program, your program might behave strangely. ("I entered 3 so why does it say 56892???") If it's overwriting into another process's memory, you'll probably get a segmentation fault, which you can at least debug.

    But far worse things might happen. You might start overwriting your executable code and change the behaviour of your program, for example.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    see edit...



    it never crashed...it hung, as though it were in an infinite loop, but CPU usage was 0%.

    somehow the application's main thread was suspended instead of the intended thread; which implies that the method of interest was erroneously executed sequentially instead of in it's own thread.
    Last edited by m37h0d; 07-24-2008 at 11:52 AM.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    I'm sorry, I forgot which thread I was replying to . . . my fault.

    You could, perhaps, have run the program in a debugger, and interrupted it when it froze . . . if it froze while taking zero CPU, it's possible that the thread was just waiting for something (or two threads were waiting for each other . . .), and you'd at least be able to see where it was waiting.

    Or you could just have examined your threading code very, very carefully, since it seems like it was a threading issue.

    Anyway . . . you've fixed it now, haven't you?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    yes, i did, but thanks for pointing me to that other thread; lots of good stuff in there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 09:48 AM
  2. Debugging Dev C++
    By tuurb046 in forum Tech Board
    Replies: 10
    Last Post: 08-16-2007, 12:51 PM
  3. gdb no debugging symbols found
    By Laserve in forum Linux Programming
    Replies: 8
    Last Post: 09-17-2006, 08:56 AM
  4. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  5. Timing in Windows
    By steinberg in forum Windows Programming
    Replies: 3
    Last Post: 07-14-2002, 12:43 AM

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