Re: Fix for bug in testgthread on DEC OSF 4.0d



Description:
crash in glib-1.2.8/gthread/testgthread.c, line 198. (joint_thread)

I use POSIX threads implementations.
The macro join_thread is defined with:
  #define join_thread(thread) \
  pthread_join ((pthread_t)GPOINTER_TO_UINT (thread), NULL)



Solution:
Remove the GPOINTER_TO_UINT  cast in the macro, because pthread_t if defined as a 64 bit
struct pointer,
which doesn't fit in an unsigned int (32 bit).

The definitions are:
#define GPOINTER_TO_UINT(p)     ((guint) (gulong) (p))
typedef unsigned long   gulong; (64 bits)
typedef unsigned int    guint; (32 bits)

I have tested:
sizeof(unsigned int)=4
sizeof(unsigned long=8
sizeof(void *)=8
sizeof(pthread_t)=8


in /usr/include/pthread.h:

typedef struct __pthreadTeb_t {
    __pthreadLongAddr_p _Pfield(reserved1);     /* Reserved to DECthreads */
...
...
    __pthreadLongAddr_t _Pfield(stack_hiwater); /* V1: lowest known SP */
 } pthreadTeb_t, *pthreadTeb_p;


# if defined (_PTHREAD_ALLOW_MIXED_PROTOS_) && defined (__INITIAL_POINTER_SIZE)
typedef pthreadTeb_p    pthread_t;      /* Long pointer if possible */
#  pragma __required_pointer_size __restore
# elif defined (_PTHREAD_ENV_ALPHA) && defined (_PTHREAD_ENV_VMS)
typedef uint64          pthread_t;      /* Force 64 bits anyway */
# else
******* THIS definition is used on my machine *********
typedef pthreadTeb_p    pthread_t;      /* Pointers is pointers */
# endif
#endif



crash in glib-1.2.8/gthread/testgthread.c, line 198. (





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]