Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 2004 22:18:27 GMT
From:      Archie Cobbs <archie@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   threads/75374: pthread_kill() ignores SA_SIGINFO flag
Message-ID:  <200412212218.iBLMIRtD061757@beast.freebsd.org>
Resent-Message-ID: <200412212220.iBLMKHEr025057@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         75374
>Category:       threads
>Synopsis:       pthread_kill() ignores SA_SIGINFO flag
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 21 22:20:17 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Archie Cobbs
>Release:        FreeBSD 5.3-STABLE alpha
>Organization:
Packet Design
>Environment:
System: FreeBSD beast.freebsd.org 5.3-STABLE FreeBSD 5.3-STABLE #527: Tue Dec 21 15:02:03 UTC 2004 root@beast.freebsd.org:/usr/src/sys/alpha/compile/BEAST alpha

Also happens on FreeBSD 4.10.

>Description:
	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.

>How-To-Repeat:

/*
 * 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;
}

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

	memset(&sa, 0, sizeof(sa));
	sigemptyset(&sa.sa_mask);
	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;
}

>Fix:

Unknown.

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412212218.iBLMIRtD061757>