[omniORB] Sun C++ 5 or 6 "throw" is not thread safe.

Arnault Bonafos arnault.bonafos@tumbleweed.com
Wed, 16 Aug 2000 12:07:02 -0700


Hello,
Although I'm not sure what does the given thr program I've tried it and ran it
with thr 200. It never crashed.
My machine is a solaris 7 with workshop 5.0 and CC 5.0, and all the patches
applied as stated in
http://access1.sun.com/workshop/current-patches.html

The patch list I applied is as follow.
--
For Workshop 5.0 you need the following patches

107295-01 WorkShop IPE 5.0: Patch for WorkShop IPE 5.0
107311-11 C++ 5.0: Patch for C++ 5.0 compiler
107354-02 TeamWare 2.1: Patch for TeamWare 2.1
107355-06 WorkShop IPE 5.0: Patch for dbx
107357-09 Compiler Common 5.0: Patch C 5.0, C++ 5.0, F77 5.0, F90 2.0
107740-01 LoopTool 5.0: Patch for Sun WorkShop LoopTool 5.0
107742-01 WorkShop IPE 5.0: Patch for Performance Analyzer

--
For the OS 5.7 you will need (sparc 32 bits):

106327-08  SunOS 5.7: Shared library patch for C++
106748-04  SunOS 5.7: /usr/ccs/bin/sccs and /usr/ccs/bin/make patch


Sai-Lai Lo wrote:

> Unfortunately, things are not as simple as it first looks.
> I changed the test program to use pthread and corrected some obvious
> mistakes and it no longer SEGV.
>
> My omniorb test program still SEGV in exception unwinding though.
>
> Sai-Lai
>
> The revised test is as follows:
>
> #include <pthread.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/types.h>
> #include <sys/time.h>
>
> //#define SAFE
>
> extern "C" void* do_it(void*);
> int *now;
>
> #ifdef SAFE
> pthread_mutex_t throw_mut;
> #endif
>
> int
> main(int argc, char *argv[]) {
>   if (argc != 2) {
>     fprintf(stderr, "Usage: throw numthreads\n");
>     exit(1);
>   }
>
>   int numthreads = atoi(argv[1]);
>
> #ifdef SAFE
>   pthread_mutex_init(&throw_mut,NULL);
> #endif
>
>   now = new int[numthreads];
>   for(int i = 0; i<numthreads; i++) {
>     now[i] = 0;
>     pthread_t id;
>     pthread_create(&id,NULL,do_it,(void*)i);
>   }
>
>   while(1) {
>     struct timeval to = {0, 10000};
>     if (select(0, 0, 0, 0, &to) == -1) {
>       perror("select");
>       exit(1);
>     }
>     for (int i=0; i<numthreads; i++)
>       now[i] = 1;
>     }
>
>   return(0);
> }
>
> class Excp {
> public:
>   Excp() {}
> };
>
> void*
> do_it(void* arg) {
>
>   int me = (int) arg;
>   while(1) {
>     try {
>       while (1) {
>         if (now[me] == 1) {
>  #ifdef SAFE
>           pthread_mutex_lock(&throw_mut);
>  #endif
>           throw(Excp());
>         }
>       }
>     } catch (Excp &x) {
>       now[me] = 0;
>  #ifdef SAFE
>       pthread_mutex_unlock(&throw_mut);
>  #endif
>     }
>   }
>   return 0;
> }
>
> --
> Sai-Lai Lo                                   S.Lo@uk.research.att.com
> AT&T Laboratories Cambridge           WWW:   http://www.uk.research.att.com
> 24a Trumpington Street                Tel:   +44 1223 343000
> Cambridge CB2 1QA                     Fax:   +44 1223 313542
> ENGLAND
>
> ---

--
Arnault Bonafos     Software Engineer
Tumbleweed    Communications    Corp.
ph: (650) 216-2027  fx: (650) 216-2003