threads/75374: pthread_kill() ignores SA_SIGINFO flag

Archie Cobbs archie at
Tue Dec 21 14:20:18 PST 2004

>Number:         75374
>Category:       threads
>Synopsis:       pthread_kill() ignores SA_SIGINFO flag
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 21 22:20:17 GMT 2004
>Originator:     Archie Cobbs
>Release:        FreeBSD 5.3-STABLE alpha
Packet Design
System: FreeBSD 5.3-STABLE FreeBSD 5.3-STABLE #527: Tue Dec 21 15:02:03 UTC 2004 root at alpha

Also happens on FreeBSD 4.10.

	When a signal handler is set with the SA_SIGINFO flag,
	the signal is supposed to be delivered with extra information
	including the siginfo_t and ucontext_t structures.

	pthread_kill() seems to ignore this flag, at least when
	sending the signal to oneself.


 * Note that the program below prints "info=0x0 ctx=0x0" which shows that
 * no SA_SIGINFO context is being passed
 * Compile: cc -Wall -o bug bug.c -pthread

#include <err.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static void
handler(int sig, siginfo_t *info, void *ctx)
        printf("info=%p ctx=%p\n", info, ctx);

static void *
entry(void *arg)
	pthread_kill(pthread_self(), SIGSEGV);
	return NULL;

main(int ac, char **av)
	struct sigaction sa;
	pthread_t tid;

	memset(&sa, 0, sizeof(sa));
	sigaddset(&sa.sa_mask, SIGSEGV);
	sa.sa_flags = SA_SIGINFO | SA_NODEFER;
	sa.sa_sigaction = handler;
	if (sigaction(SIGSEGV, &sa, NULL) == -1)
		err(1, "sigaction");
	if ((errno = pthread_create(&tid, NULL, entry, NULL)) != 0)
		err(1, "pthread_create");
	if ((errno = pthread_join(tid, NULL)) != 0)
		err(1, "pthread_join");
	return 0;




More information about the freebsd-threads mailing list