This is the mail archive of the gcc-bugs@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]

[Bug bootstrap/43170] gcc 4.5 20100218 bootstrap compare fails on os x 10.6



------- Comment #67 from iains at gcc dot gnu dot org  2010-06-03 16:12 -------
I am puzzled by this apparent fail when the tests that depend on the variables
being distinct are all passing.
So, I think I've got a hunch; 

If the spawned thread finishes before pthread_create () returns, then the
allocation for the thread's version of 'a' will have been released.    

There is nothing to stop malloc from allocating the same block to the main
thread version of 'a' when it is asked for.

I would be reluctant to draw too many conclusions from current trunk since the
emutls has a "work-around" fix in it - but putting a usleep (1000) into the
x86_64 spawned thread works.  

=== 

On darwin9 ppc/i686 with the patch @ comment #26 of PR44132 applied: 

using this driver to do uninstalled tests:
---
#!/bin/sh
i=0
while [ $(( $i < 1000000 )) ]
do
  i=`expr $i + 1`
  r=`DYLD_LIBRARY_PATH=./gcc ./tls.ex`
  if [ $? != 0 ]
  then
    printf "%7d : %s\n" $((i)) "$r"
  fi
done
-----
and this version of the test fragment:
-----
/* { dg-do run }  */
/* { dg-require-effective-target tls  }  */

#include <pthread.h>
extern int printf (char *,...);
extern int usleep (long);
__thread int a = 5 ; 
static int *a_in_other_thread;

static void *
thread_func (void *arg)
{
/*  usleep (1000);*/
  a_in_other_thread = &a;
  a += 5 ;
  *((int *) arg) = a ;
  return (void *)0;
}

int
main ()
{
  pthread_t thread;
  void *thread_retval;
  int *a_in_main_thread;
  int thrd_arg;

  a_in_main_thread = &a;

  if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, &thrd_arg))
    return 0;

  if (pthread_join (thread, &thread_retval))
    return 0;

  if (a != 5 || thrd_arg != 10 || (a_in_other_thread == a_in_main_thread))
  {
     printf ("FAIL: a = %d thrd_a = %d address = 0x%0x\n", 
                    a, thrd_arg, a_in_main_thread);
     return 1 ;
  }
  return 0;
}

----
this has been running for 2hrs w/out a fail so far on both ppc and i686 d9.. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43170


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