Results 1 to 7 of 7

Thread: Everything catches Segfault. Except Debugger.

  1. #1
    Join Date
    Apr 2006
    Location
    Vancouver, BC, Canada
    Beans
    146
    Distro
    Ubuntu 8.04 Hardy Heron

    Everything catches Segfault. Except Debugger.

    I have minimal GDB / debugging knowledge in general. Just enough to make it work and and fix crashes. I'm having a problem I've never encountered before though: I have a program which reproducibly and consistently segfaults, but when run in GDB to detect the error, it doesn't segfault and exits noramlly. I'm having a hard time wrapping my mind around this.

    Can't post code ATM and obviously don't expect anyone to fix the problem. I'm just wondering if anyone could shed light on how such a thing could happen.
    Quote Originally Posted by Pimientito
    NEVER EVER give a gypsy player an unprotected guitar to play. It will end in tears!

  2. #2
    Join Date
    Jun 2010
    Location
    UK
    Beans
    206
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Everything catches Segfault. Except Debugger.

    If I understand you right, it segfaults except when you run it under gdb. In that case you can debug the old fashioned way, with lots of 'printf's [=

  3. #3
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Everything catches Segfault. Except Debugger.

    Problems like that are either indicative of :
    1) Race conditions - i.e. threaded code where the act of using the debugger changes the order the threads run.
    2) Stack/Memory corruption issues - which aren't caught by the debugger as it changes the memory layout of the processes.

    Have you used Valgrnd to look for memory corruptions.

    You may find that if it is a race condition problem, that putting in printf's changes the nature of the problem - or even makes it dissapear - they can be nasty to find.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  4. #4
    Join Date
    Apr 2006
    Location
    Vancouver, BC, Canada
    Beans
    146
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Everything catches Segfault. Except Debugger.

    Quote Originally Posted by DanielWaterworth View Post
    If I understand you right, it segfaults except when you run it under gdb. In that case you can debug the old fashioned way, with lots of 'printf's [=
    Yeah, that's what I figured. The main question is how could something conceivably crash in every scenario, yet run without incident in the debugger?

    i just don't understand it.
    Quote Originally Posted by Pimientito
    NEVER EVER give a gypsy player an unprotected guitar to play. It will end in tears!

  5. #5
    Join Date
    Jun 2010
    Location
    UK
    Beans
    206
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Everything catches Segfault. Except Debugger.

    Are you using threads? Race conditions are something I forgot about and would be a good thing to rule out.

  6. #6
    Join Date
    Apr 2006
    Location
    Vancouver, BC, Canada
    Beans
    146
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Everything catches Segfault. Except Debugger.

    Quote Originally Posted by Tony Flury View Post
    Problems like that are either indicative of :
    1) Race conditions - i.e. threaded code where the act of using the debugger changes the order the threads run.
    2) Stack/Memory corruption issues - which aren't caught by the debugger as it changes the memory layout of the processes.

    Have you used Valgrnd to look for memory corruptions.

    You may find that if it is a race condition problem, that putting in printf's changes the nature of the problem - or even makes it dissapear - they can be nasty to find.
    i actually traced the problem to glTexImage2D / the image I was using, so #2 is almost certainly the problem. Since the OP i've fixed it.

    I was just interested in how the debugger of all things could miss it and exit normally. This explains it to some extent.
    Quote Originally Posted by Pimientito
    NEVER EVER give a gypsy player an unprotected guitar to play. It will end in tears!

  7. #7
    Join Date
    Apr 2006
    Location
    Vancouver, BC, Canada
    Beans
    146
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Everything catches Segfault. Except Debugger.

    Quote Originally Posted by DanielWaterworth View Post
    Are you using threads? Race conditions are something I forgot about and would be a good thing to rule out.
    Nope. At least not on my own end. I haven't had the misfortune of dealing with race conditions yet.
    Quote Originally Posted by Pimientito
    NEVER EVER give a gypsy player an unprotected guitar to play. It will end in tears!

Bookmarks

Posting Permissions

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