This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Tweak g++.eh/badalloc1.C (for *-*-freebsd* -pthread only)


FAIL: g++.eh/badalloc1.C  Execution test

This test has failed on FreeBSD with -pthread for about 3 years.  I
think it would be better to run the test in a manner that nominally
works in order to catch a real regression.  Even though this test is
in not threaded, the issue is that merely linking with -pthread on
FreeBSD causes __gthread_active_p() to be true (i.e. why the issue
isn't seen on all platforms when their test suite is run -pthread or
the port's equivalent).  That, in turn, causes a behavior change in EH
support on thread-enabled platforms.  In particular, it needs to
allocate per-thread memory at the time of the first exception is throw
within the thread's context (at least on FreeBSD).  This is a known
design issue; robust threaded EH-C++ would prime every worker thread.

Nathan, as the owner of the test: OK for me to install?  You will note
that the change only affects FreeBSD systems when linked against its
thread library.

Regards,
Loren

Index: gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C,v
retrieving revision 1.9
diff -c -r1.9 badalloc1.C
*** gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C	1 May 2003 02:02:38 -0000	1.9
--- gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C	16 Dec 2003 11:04:18 -0000
***************
*** 1,5 ****
  // { dg-do run { xfail xstormy16-*-* *-*-darwin* } }
! // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
  // Contributed by Nathan Sidwell 6 June 2000 <nathan@codesourcery.com>
  
  // Check we can throw a bad_alloc exception when malloc dies.
--- 1,5 ----
  // { dg-do run { xfail xstormy16-*-* *-*-darwin* } }
! // Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
  // Contributed by Nathan Sidwell 6 June 2000 <nathan@codesourcery.com>
  
  // Check we can throw a bad_alloc exception when malloc dies.
***************
*** 14,21 ****
--- 14,28 ----
  #ifdef STACK_SIZE
  const int arena_size = 256;
  #else
+ #ifdef __FreeBSD__
+ // FreeBSD with threads requires even more space at initialization time.
+ #include "bits/c++config.h"
+ #include "bits/gthr.h"
+ const int arena_size = 131072;
+ #else
  const int arena_size = 32768;
  #endif
+ #endif
  
  struct object
  {
***************
*** 98,103 ****
--- 105,121 ----
  
  int main()
  {
+ #ifdef __FreeBSD__
+ // FreeBSD with threads fails the test unless each thread primes itself.
+   if (__gthread_active_p())
+     {
+       try{fn_throw();}
+       catch(int a){}
+     }
+ // This was added to test with well-known idiom to detect regressions here
+ // rather than always failing with -pthread.
+ #endif
+ 
    fail = 1;
  
    try{fn_throw();}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]