Bug 9550 - sigprocmask does not work on FreeBSD to stop further signals in a signal handler
Summary: sigprocmask does not work on FreeBSD to stop further signals in a signal handler
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: File services (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-08 19:54 UTC by Richard Sharpe
Modified: 2020-12-11 08:28 UTC (History)
1 user (show)

See Also:


Attachments
git-am patchset for 4.0.x and master. (6.97 KB, patch)
2013-01-14 23:25 UTC, Jeremy Allison
rsharpe: review+
Details
git-am patchset for 3.6.next. (5.36 KB, patch)
2013-01-15 18:38 UTC, Jeremy Allison
rsharpe: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Sharpe 2013-01-08 19:54:00 UTC
The code in lib/tevent/tevent_signal.c:tevent_common_signal_handler_info does not correctly switch off further signals when TEVENT_SA_INFO_QUEUE_COUNT is reached.

This is at least the case for FreeBSD 8.0. I am not sure yet about subsequent releases.

The code is:

        if (count+1 == TEVENT_SA_INFO_QUEUE_COUNT) {
                /* we've filled the info array - block this signal until
                   these ones are delivered */
                sigset_t set;
                sigemptyset(&set);
                sigaddset(&set, signum);
                sigprocmask(SIG_BLOCK, &set, NULL);
                TEVENT_SIG_INCREMENT(sig_state->sig_blocked[signum]);
        }

Under FreeBSD 8.0 we have to use:

                sigaddset(&((ucontext_t *)uctx)->uc_sigmask, signum);

and include <sys/ucontext.h>.

It seems that we need a configure test or something for this, but I am not sure how to detect it.
Comment 1 Richard Sharpe 2013-01-08 20:51:48 UTC
Perhaps we need a symbol like NEED_FREEBSD_STYLE_SIGBLOCK in config.h.
Comment 2 Richard Sharpe 2013-01-08 21:03:00 UTC
Perhaps something like:

dnl We need to use a fugly hack to stop further signals on FreeBSD
AC_MSG_CHECKING([whether to use FreeBSD Style signal stopping])
case "$host" in
*-freebsd*)
	AC_DEFINE(NEED_FREEBSD_SIGSTOP, "yes",
			[need FreeBSD style signal stopping])
	;;
esac
Comment 3 Jeremy Allison 2013-01-14 23:25:28 UTC
Created attachment 8429 [details]
git-am patchset for 4.0.x and master.

Richard, please review and push to master if you're happy with this.

I'll also create a 3.6.x version.

Jeremy.
Comment 4 Jeremy Allison 2013-01-15 18:38:36 UTC
Created attachment 8434 [details]
git-am patchset for 3.6.next.
Comment 5 Richard Sharpe 2013-01-15 19:08:42 UTC
Comment on attachment 8429 [details]
git-am patchset for 4.0.x and master.

Looks good to me
Comment 6 Richard Sharpe 2013-01-15 19:09:49 UTC
(In reply to comment #3)
> Created attachment 8429 [details]
> git-am patchset for 4.0.x and master.
> 
> Richard, please review and push to master if you're happy with this.

I should be able to push this tonight.
Comment 7 Jeremy Allison 2013-01-15 19:38:10 UTC
Richard,

Metze already pushed this (and Karolin already pushed to 4.0.next).

Just give the 3.6 version a +1 and I'll re-assign to Karolin for inclusion.

Cheers,

Jeremy.
Comment 8 Richard Sharpe 2013-01-15 19:43:37 UTC
Comment on attachment 8434 [details]
git-am patchset for 3.6.next.

Looks good.
Comment 9 Jeremy Allison 2013-01-15 19:47:40 UTC
Re-assigning to Karolin for inclusion in 3.6.next.

Jeremy.
Comment 10 Karolin Seeger 2013-01-16 08:53:30 UTC
Pushed to v3-6-test.
Closing out bug report.

Thanks!
Comment 11 Stefan Metzmacher 2013-01-16 11:06:36 UTC
This is needed for 4.0 too
Comment 12 Karolin Seeger 2013-01-17 08:04:48 UTC
(In reply to comment #11)
> This is needed for 4.0 too

Pushed to autobuild-v4-0-test.
Comment 13 Karolin Seeger 2013-01-18 08:39:05 UTC
Pushed to v4-0-test.
Closing out bug report.

Thanks!