Signal handler for assert()

This is a discussion on Signal handler for assert() within the Linux Programming forums, part of the Platform Specific Boards category; Still not seeing any real solution for the original question; everyone keeps falling back on the one thing I cannot ...

  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,169
    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%.

Page 2 of 2 FirstFirst 12
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, 11:58 AM
  5. signal handler
    By falconetti in forum C Programming
    Replies: 1
    Last Post: 02-21-2002, 06:54 PM

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