Thread: Signal handler for assert()

  1. #16
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Still not seeing any real solution for the original question; everyone keeps falling back on the one thing I cannot do (which I have made abundantly clear). So there is no way to catch this assertion? None?
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #17
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Even the idea of catching it is wrong, unless you somehow can jump out of the function. Otherwise, you're going to dereference a NULL pointer. Turn off assertions, and you'll probably get a segfault, or some other amazingly unpredictable behaviour. Why not just initialise the status?

  3. #18
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    I agree, zacs. I suggested that in a couple of my posts as well. If an assertion is failing (or a signal is being raised, or an exception is being thrown) and you can't rewrite the offending code, the real solution is avoiding the circumstances that make it signal a failure.

    Without visibility of details of the offending class, it's hard to give specific advice on alternatives.

    jeffcobb: as I said in the second post, there is no way to swallow a SIGABRT signal in a manner that allows your program to just continue. Short of redesigning how your operating system handles that signal, which I assume would be excessive.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with infinite loop in signal handler
    By semun in forum C Programming
    Replies: 6
    Last Post: 07-22-2009, 01:15 PM
  2. Replies: 3
    Last Post: 07-07-2009, 10:05 AM
  3. Signal handler function - pointer to this gets lost
    By maus in forum C++ Programming
    Replies: 1
    Last Post: 07-01-2009, 09:10 AM
  4. using a signal handler to kill processes
    By dinjas in forum C Programming
    Replies: 2
    Last Post: 03-16-2005, 12:58 PM
  5. signal handler
    By falconetti in forum C Programming
    Replies: 1
    Last Post: 02-21-2002, 07:54 PM