Open Suse 10 seg fault

Okay, so here is some code that when compiled on Fedora Core 6 works great, but when I compile and run it on OpenSuse 10 it gives back a seg fault when trying to join the 2nd thead.

#include <pthread.h>
#include <stdio.h>

int print_message_function( void *ptr );

int x = 1;

main()
{
        pthread_t thread1, thread2;
        int thread1result, thread2result;
        char *message1 = "Hello";
        char *message2 = "World";
        pthread_attr_t *pthread_attr_default = NULL;
        pthread_attr_t *pthread_attr_default2 = NULL;

        printf("Begin\n");
        pthread_create( &thread1, pthread_attr_default,
                        (void*)&print_message_function, (void*) message1);
        pthread_create(&thread2, pthread_attr_default2,
                        (void*)&print_message_function, (void*) message2);

        pthread_join(thread1, (void *)&thread1result);
        printf("\nEnd thread1 with %d\n", thread1result);

        pthread_join(thread2, (void *)&thread2result);
        printf("\nEnd thread2 with %d\n", thread2result);

        exit(0);
}

int print_message_function( void *ptr )
{
        char *message;
        message = (char *) ptr;
        printf("%s ", message);
        fflush(stdout);
        return x++;
}

I compile using the -lpthread flag. Doesn't anyone have any suggestions or know why?

Lying about prototypes and return types doesn't help.

The function prototype for a thread is

void *my_func(void *);

and the returned argument from a pthread_join is a void *.

Your typecasting as you have done it is unsafe.

So you should have

void *threadresult;

and

return (void *)x++;

Are you compiling with -D_REENTRANT ?