FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

LinkBack Thread Tools
Old 09-27-2012, 01:35 PM
Georgiy Kirichenko
Default gcc-4.7: 'terminate called without an active exception' after unblocking in pending signal handler with pthread_exit


I have strange behaviour for this simple code (compiled with gcc test.cpp -
lpthread -o test):
#include <stdio.h>
#include <signal.h>
#include <pthread.h>
#include <wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

void *thread_proc(void *arg)
sigset_t sigs;
sigaddset(&sigs, SIGTERM);
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
fprintf(stderr, "start thread
fprintf(stderr, "stop thread
pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);

void thread_signal(int signum)

int main(int argc, char **argv)
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = thread_signal;
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, 0);

pthread_t thread;
pthread_create(&thread, NULL, thread_proc, NULL);
fprintf(stderr, "kill thread
pthread_kill(thread, SIGTERM);
fprintf(stderr, "join thread
pthread_join(thread, NULL);
return 0;

This sample produce 'terminate called without an active exception' exception
after pthread_exit(0).

For gcc 4.6, 4.4 its works fine. With -fno-exceptions flag its works. When i
compile this as c code (gcc test.c -lpthread -o test) its works also fine.


To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/7755393.K9rTZ9PzKr@georgiy

Thread Tools

All times are GMT. The time now is 02:24 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org