Menu

#104 Fix signal handler

open-later
None
7
2007-02-09
2007-02-07
No

The function "exit()" does not belong to the list of async-signal-safe functions.
See section "2.4.3 Signal Actions" from the document "2.4 Signal Concepts".
http://opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
http://opengroup.org/onlinepubs/009695399/functions/_Exit.html

Should this call be replaced by a safe alternative in your function "mysigdie"?
http://bogofilter.cvs.sourceforge.net/bogofilter/bogofilter/src/sighandler.c?revision=1.7&view=markup
http://groups.google.de/group/comp.unix.programmer/browse_frm/thread/3ab94f021cf9a43c/af93e23fe1234e05

Discussion

  • David Relson

    David Relson - 2007-02-08

    Logged In: YES
    user_id=30510
    Originator: NO

    Markus,

    The link applies to multi-threaded apps, right? Bogofilter is not multi-threaded.

    If you care to submit a patch, it will be considered.

    David

     
  • Markus Elfring

    Markus Elfring - 2007-02-08
    • assigned_to: nobody --> relson
     
  • Matthias Andree

    Matthias Andree - 2007-02-09

    Logged In: YES
    user_id=2788
    Originator: NO

    Hi Markus, thanks for the report.

    David, signal handlers are worse than threads and can really mess up the code, as all involved functions (those we "rip" the program flow out of and those we execute and all their callees) have to be reentrant. I'm grabbing this bug and will look into it.

     
  • Matthias Andree

    Matthias Andree - 2007-02-09
    • priority: 5 --> 7
    • assigned_to: relson --> m-a
    • status: open --> open-later
     
  • Matthias Andree

    Matthias Andree - 2007-02-14

    Logged In: YES
    user_id=2788
    Originator: NO

    Turns out to be a non-trivial fix that requires

    (a) some policy decisions internally

    (b) major code changes - not necessarily considering lines touched, but rather with respect to the power or invasiveness of the changes.

    We won't have a quick fix unfortunately.

    If and only if you are either using sqlite3, or berkeleydb in transactional mode, as a temporary solution, replace exit() by _exit() in said function. If you're using this on a non-transactional berkeleydb or QDBM database, you can corrupt the database this way. (Although it is not clear to me if this won't happen anyways if you interrupt the application at the wrong point in time.)

     

Log in to post a comment.