public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* about exception type issuse
@ 2009-02-17  8:04 Guan Jun He
  2009-02-17 12:39 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Guan Jun He @ 2009-02-17  8:04 UTC (permalink / raw)
  To: gcc-help

Dear All

    I write the following code,and get the an unknow exception.Would any
body tell me what the exception is?why it can be catched by
catch(...),but can not be catched by user's code.

best,
Guanjun

code:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdexcept>
#include <ios>
#include <fstream>
#include <csignal>
#include <iostream>
#include <exception>
#include <exception_defines.h>
#include <unwind.h>
typedef unsigned _Unwind_Exception_Class
__attribute__((__mode__(__DI__)));

void *thread(void*)
{
        int i;
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);

pthread_setcanceltype(/*PTHREAD_CANCEL_ASYNCHRONOUS*/PTHREAD_CANCEL_DEFERRED, 0);
        try
        {
                for(i=0;/*i<3*/;i++) {
                        //pthread_testcancel();
                        printf("This is a pthread.\n");
                        //pthread_testcancel();
                }
        }catch(.../*_Unwind_Reason_Code &n*//*struct _Unwind_Exception
&b*//*_Unwind_Exception_Class &u*/)
        {
                printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This
is the child thread: \n");/*%d .\n", n);*/
                //throw;
                //a.what();
                /*do nothing*/
        }
        return 0;
}

int main(void)
{
        pthread_t id;
        int ret;
        ret=pthread_create(&id,NULL, thread,NULL);
        if(ret!=0){
                printf ("Create pthread error!\n");
                exit (1);
        }
        usleep(100);
        printf("********************This is the main thread.\n");
        pthread_cancel(id);
        printf("********************This is the main thread.\n");
        //pthread_join(id,0);
        return (0);
}






^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: about exception type issuse
  2009-02-17  8:04 about exception type issuse Guan Jun He
@ 2009-02-17 12:39 ` John (Eljay) Love-Jensen
  0 siblings, 0 replies; 3+ messages in thread
From: John (Eljay) Love-Jensen @ 2009-02-17 12:39 UTC (permalink / raw)
  To: Guan Jun He, gcc-help

Hi Guanjun,

I compiled and ran your code on my machine.

No unknown exception.

Here's the output:

# g++ test.cpp
# ./a.out 
This is a pthread.
This is a pthread.
********************This is the main thread.
This is a pthread.
********************This is the main thread.
This is a pthread.
This is a pthread.
This is a pthread.
This is a pthread.
This is a pthread.

SIncerely,
--Eljay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: about exception type issuse
       [not found] <499B4AB702000054000073AD@lucius.provo.novell.com>
@ 2009-02-18  3:36 ` Guan Jun He
  0 siblings, 0 replies; 3+ messages in thread
From: Guan Jun He @ 2009-02-18  3:36 UTC (permalink / raw)
  To: eljay; +Cc: gcc-help

Hi Eljay

    Are you using the NPTL?and what's your NPTL(glibc) version and gcc
version?

best,
Guanjun

在 2009-02-17二的 04:37 -0800,John (Eljay) Love-Jensen写道:
> Hi Guanjun,
> 
> I compiled and ran your code on my machine.
> 
> No unknown exception.
> 
> Here's the output:
> 
> # g++ test.cpp
> # ./a.out 
> This is a pthread.
> This is a pthread.
> ********************This is the main thread.
> This is a pthread.
> ********************This is the main thread.
> This is a pthread.
> This is a pthread.
> This is a pthread.
> This is a pthread.
> This is a pthread.
> 
> SIncerely,
> --Eljay

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-18  3:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-17  8:04 about exception type issuse Guan Jun He
2009-02-17 12:39 ` John (Eljay) Love-Jensen
     [not found] <499B4AB702000054000073AD@lucius.provo.novell.com>
2009-02-18  3:36 ` Guan Jun He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).