Skip to content
Snippets Groups Projects
  • Nadav Har'El's avatar
    e6208f1e
    Add, and use, new abort(msg) function · e6208f1e
    Nadav Har'El authored
    Recently Guy fixed abort() so it will *really* not infinitely recurse trying
    to print a message, using a lock, causing a new abort, ad infinitum.
    
    Unfortunately, that didn't fix one remaining case: DUMMY_HANDLER (see
    exceptions.cc) used the idiom
    
            debug(....); abort();
    
    which can again cause infinite recursion - a #GP calls debug() which causes a
    new #GP, which again calls debug, etc.
    
    Instead of the above broken idiom, created a new function abort(msg), which is
    just like the familiar abort(), just changes the "Aborted" message to some
    other message (a constant string). Like abort(), the new variant abort(msg) will
    only print the message once even if called recursively - and uses a lockless
    version of debug().
    
    Note that the new abort(msg) is a C++-only API. C will only see the abort(void)
    which is extern "C". At first I wanted to call the new function panic(msg) and
    export it to C, but gave when I saw the name panic() was already in use in a
    bunch of BSD code.
    e6208f1e
    History
    Add, and use, new abort(msg) function
    Nadav Har'El authored
    Recently Guy fixed abort() so it will *really* not infinitely recurse trying
    to print a message, using a lock, causing a new abort, ad infinitum.
    
    Unfortunately, that didn't fix one remaining case: DUMMY_HANDLER (see
    exceptions.cc) used the idiom
    
            debug(....); abort();
    
    which can again cause infinite recursion - a #GP calls debug() which causes a
    new #GP, which again calls debug, etc.
    
    Instead of the above broken idiom, created a new function abort(msg), which is
    just like the familiar abort(), just changes the "Aborted" message to some
    other message (a constant string). Like abort(), the new variant abort(msg) will
    only print the message once even if called recursively - and uses a lockless
    version of debug().
    
    Note that the new abort(msg) is a C++-only API. C will only see the abort(void)
    which is extern "C". At first I wanted to call the new function panic(msg) and
    export it to C, but gave when I saw the name panic() was already in use in a
    bunch of BSD code.