Closed Bug 171343 Opened 22 years ago Closed 22 years ago

nsProfileAccess should use SA_SIGINFO and sa_sigaction

Categories

(Core Graveyard :: Profile: BackEnd, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
mozilla1.2beta

People

(Reporter: bryner, Assigned: bryner)

Details

Attachments

(1 file, 2 obsolete files)

Per the POSIX specification, you can pass SA_SIGINFO as a flag to sigaction()
and get your handler called with 3 paramters instead of 1, i.e.:

void handler(int signum, siginfo_t* info, void* context);

nsProfileAccess currently does not set this flag.  The problem is that if you
have another signal handler installed (before nsProfileAccess's handler) which
wants the extra parameters, it will not receive them.

Since there's no reason not to get the extra info passed to our handler, we
should do this, so we can pass it up to the next handler in the chain (if it
uses SA_SIGINFO).
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.2beta
Attached patch patch (obsolete) — Splinter Review
Note that I specifically do not assume in this patch that sa_handler and
sa_sigaction are a union, even though it seems to be in almost all cases.  POSIX
does not require this.  So I always check the SA_SIGINFO flag and access the
appropriate member based on that.
Comment on attachment 100983 [details] [diff] [review]
patch

> #define CATCH_SIGNAL(signame)                                                 \
>     PR_BEGIN_MACRO                                                            \
>         if (sigaction(signame, NULL, &oldact) == 0 &&                         \
>-            oldact.sa_handler != SIG_IGN)                                     \
>+            (((oldact.sa_flags & SA_SIGINFO) &&                               \
>+               oldact.sa_sigaction != (my_sigaction_t) SIG_IGN) ||            \
>+             (!(oldact.sa_flags & SA_SIGINFO) && oldact.sa_handler != SIG_IGN))) \

This violates the 80th column (79 is the last usable one due to wrapping bugs
in some Emacses), but what's more, it should use ?: like so:

+	     ((oldact.sa_flags & SA_SIGINFO)				      
\
+	      ? oldact.sa_sigaction != (my_sigaction_t) SIG_IGN)	      
\
+	      : oldact.sa_handler != SIG_IGN))) 			      
\

Fix that nit, and sr=brendan@mozilla.org, esp. if your latest testing shows
that it works :-)

/be
Attachment #100983 - Flags: superreview+
Attached patch patch #2 (obsolete) — Splinter Review
Address brendan's comments; #include <signal.h> from nsProfileAccess.h for
access to the siginfo_t typedef (this must have been getting brought in some
other way on OS X).
Attachment #100983 - Attachment is obsolete: true
Comment on attachment 100984 [details] [diff] [review]
patch #2

carrying over sr=brendan
Attachment #100984 - Flags: superreview+
Comment on attachment 100984 [details] [diff] [review]
patch #2

r=ccarlen
Attachment #100984 - Flags: review+
siginfo_t and SA_SIGINFO are not defined on OS X 10.1.  I backed out the patch
until I can come up with an autoconf test.
Attached patch patch #3Splinter Review
Add an autoconf test for siginfo_t; use the old behavior if the type is not
present.
Attachment #100984 - Attachment is obsolete: true
Comment on attachment 102126 [details] [diff] [review]
patch #3

More of a cls thing, and who knew OSX was evolving so rapidly to catch up to
Unixes of 10 years ago? ;-)  sr=brendan@mozilla.org if it helps.

/be
Attachment #102126 - Flags: superreview+
Comment on attachment 102126 [details] [diff] [review]
patch #3

a=chofmann
Attachment #102126 - Flags: approval+
checked into the trunk and CHIMERA_M1_0_1_BRANCH.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified code fix
Status: RESOLVED → VERIFIED
It seems like this might have broken talkback on Linux.  See bug 176886,
especially bug 176886 comment 10.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: