From rcarter@pinyon.org Thu Dec  2 10:15:06 1999
Return-Path: <rcarter@pinyon.org>
Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131])
	by hub.freebsd.org (Postfix) with ESMTP id E6F5214D09
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  2 Dec 1999 10:15:01 -0800 (PST)
	(envelope-from rcarter@pinyon.org)
Received: (from daemon@localhost)
	by smtp01.primenet.com (8.9.3/8.9.3) id LAA23723
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 2 Dec 1999 11:14:16 -0700 (MST)
Received: from ip-83-152.prc.primenet.com(207.218.83.152), claiming to be "pinyon.org"
 via SMTP by smtp01.primenet.com, id smtpdAAAnsaqST; Thu Dec  2 11:13:46 1999
Received: by pinyon.org (Postfix, from userid 1001)
	id CCF5456; Thu,  2 Dec 1999 11:13:24 -0700 (MST)
Message-Id: <19991202181324.CCF5456@pinyon.org>
Date: Thu,  2 Dec 1999 11:13:24 -0700 (MST)
From: rcarter@pinyon.org
Reply-To: rcarter@pinyon.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: C++ exceptions+threads fail
X-Send-Pr-Version: 3.2

>Number:         15228
>Category:       misc
>Synopsis:       C++ exceptions+threads SIGABRTs.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec  2 10:20:01 PST 1999
>Closed-Date:    Mon Dec 4 20:07:27 PST 2000
>Last-Modified:  Mon Dec 04 20:09:10 PST 2000
>Originator:     Russell L. Carter
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Conceptual Systems & Software
>Environment:

	standard -current

>Description:

	Throwing a c++ exception across threads causes core dump.

>How-To-Repeat:

$ c++ -pthread -D_THREAD_SAFE ex_test.cpp
$ ./a.out
Throwing Ex:
Caught Ex, now rethrowing it...
Caught Ex thrown from main thread.
Throwing Ex:
Caught Ex, now rethrowing it...
Abort trap (core dumped)
$

ex_test.cpp:

#include <stdio.h>
#include <pthread.h>

class Ex {};

class testEx {
public:
  void throwEx () {
    fprintf(stderr, "Throwing Ex:\n");
    throw Ex (); 
  }
};

void *
f(void *)
{
  testEx thetest;
  thetest.throwEx ();
}

void *
g(void *arg) 
{  
  try {
    f(arg);
  } catch (Ex &ex) {
    fprintf(stderr, "Caught Ex, now rethrowing it...\n");
    throw;
  }
}

int
main (void)
{
  int *arg = 0;
  
  try {
    g((void *) arg);
  } catch (Ex &ex) {
    fprintf(stderr, "Caught Ex thrown from main thread.\n");
  }
  
  pthread_t ex_thread;
  pthread_attr_t *attr = 0;
  
  try {
    pthread_create(&ex_thread, attr, g, (void *) arg);
  } catch (Ex &ex) {
    fprintf(stderr, "Caught Ex thrown from child thread.\n");
  }
  pthread_join(ex_thread, (void **) &arg);
  
  return 0;
}


>Fix:

None yet.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: deischen 
State-Changed-When: Fri Nov 17 21:02:37 PST 2000 
State-Changed-Why:  
I don't think this is a valid problem.  The test program 
creates a thread from the main program and expects the 
exception raised from the thread to be thrown back to the 
main program.  A thread is a separate execution context 
totally disjoint from the creator (until the time that 
the creator or another thread join to it). 

I am going to close this PR in a week or two if I don't 
here back from the originator. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15228 
State-Changed-From-To: analyzed->closed 
State-Changed-By: deischen 
State-Changed-When: Mon Dec 4 20:07:27 PST 2000 
State-Changed-Why:  
Does not seem to be a valid bug and exhibits desired behaviour. 
No response from originator since analyzed over 2 weeks ago. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15228 
>Unformatted:
