why pthread functions doesn't work with args from a struct?

Hello,

I got a bad problem with pthread functions (pthread_mutex_init() and pthread_create()).
The thing is that it works on x86 but not on arm le.

Here the pseudo code:

typedef struct
{
  ...
  pthread_t       thread_id;
  pthread_mutex_t mutex;
  ...
}data_struct_t;

void pthread_failed()
{
data_struct_t *var;

  var = cmalloc(sizeof(1, data_struct_t));
  if(var == NULL)
    return();

  if(EOK != pthread_mutex_init(var->mutex, NULL))  // this failed with EFAULT
   {
    perror("pthread_mutex_init() failed ");
    return();
   }  

  if(EOK != pthread_create(&var->thread_id, NULL, my_thread_func, var))  // this crashes with _Bus error (core dumped)
   {
    perror("pthread_create() failed ");
    return(NULL);
   }
}

void pthread_failed_too()
{
data_struct_t var;


  if(EOK != pthread_mutex_init(&var.mutex, NULL))  // this crashes with _Bus error (core dumped)
   {
    perror("pthread_mutex_init() failed ");
    return();
   }  

  if(EOK != pthread_create(&var.thread_id, NULL, my_thread_func, &var))  // this crashes with _Bus error (core dumped)
   {
    perror("pthread_create() failed ");
    return(NULL);
   }
}

void pthread_works()
{
pthread_t       thread_id;
pthread_mutex_t mutex;


  if(EOK != pthread_mutex_init(&mutex, NULL))  // works
   {
    perror("pthread_mutex_init() failed ");
    return();
   }  

  if(EOK != pthread_create(&thread_id, NULL, my_thread_func, NULL))  // works, too
   {
    perror("pthread_create() failed ");
    return(NULL);
   }
}

The pthread functions doesn’t work if i give it arguments from a struct, the struct could be static, too.
If i would take the thread_id and mutex out of the struct it works fine.

I can’t see the reason why the pthread functions should only work with arguments from out of a struct.

Thanks,
Robert

The problem was that used pragma pack(1) before and the pthread functions tried to access illegal mem.
That means a #pragma pack(4) solve all my problems.