All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Bernhard <michael.bernhard@domain.hid>
To: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: [Xenomai-help] SIGILL when calling pthread_cleanup_push()
Date: Mon, 3 Oct 2011 11:35:53 +0200	[thread overview]
Message-ID: <4E8981F9.9090105@domain.hid> (raw)

Hi

We are using Xenomai-2.5.6 together with Linux-2.6.35 on a PXA270 
processor. Xenomai works fine so far. However we get SIGILL when using 
pthread_cleanup_push() in a RT-thread. I now tried the same over 
Xenomai-2.6 and the behavior is still the same.

Here's a simple example which shows the problem (for Xenomai-2.6):

#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <execinfo.h>
#include <sys/mman.h>

pthread_t thread_id;

void sig_handler(int signal)
{
   void *bt[32];
   int nentries;

   printf("Cought signal: %d\n", signal);

   nentries = backtrace(bt,sizeof(bt) / sizeof(bt[0]));
   backtrace_symbols_fd(bt,nentries,fileno(stdout));
}

void cancel_func(void * arg)
{
}

void * thread_func(void * arg)
{
   /* When forcing a mode switch to Linux, SIGILL is not generated */
#if 0
   __real_printf("Force mode switch\n");
#endif

   pthread_cleanup_push (cancel_func, NULL);
   pthread_cleanup_pop(1);

   return NULL;
}

int main (int argc, char * argv[])
{
   pthread_attr_t attr;
   struct sched_param prio = {.sched_priority = 99};
	
   signal(SIGILL, sig_handler);
	
   mlockall(MCL_CURRENT | MCL_FUTURE);
	
   pthread_attr_init(&attr);
   pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
   pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
   pthread_attr_setschedparam(&attr, &prio);
	
   pthread_create(&thread_id, &attr, thread_func, NULL);

   sleep(1);
	
   pthread_join(thread_id, NULL);
	
   return 0;
}

SIGILL is not raised, when a mode switch to Linux is forced prior to 
call pthread_cleanup_push(). It is also not rised when the RT-thread 
runs under SCHED_OTHER.

The "Undefined instruction" gets incremented in /proc/xenomai/faults.

The backtrace does not reveal much information:
Cought signal: 4
./sigill[0x89bc]
/lib/libc.so.6(__default_sa_restorer_v2+0x0)[0x8bda90]
/lib/libc.so.6(__sigsetjmp+0x38)[0x8bc4f8]
./sigill[0x8a44]
/usr/xenomai/lib/libpthread_rt.so.1(+0x4448)[0x82c448]
/lib/libpthread.so.0(+0x5b60)[0x852b60]
/lib/libc.so.6(clone+0x88)[0x967c58]

What is going wrong here?

--
Michael


             reply	other threads:[~2011-10-03  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03  9:35 Michael Bernhard [this message]
2011-10-03 12:26 ` [Xenomai-help] SIGILL when calling pthread_cleanup_push() Gilles Chanteperdrix
2011-10-03 15:33   ` Gilles Chanteperdrix
2011-10-04 11:25     ` Gilles Chanteperdrix
2011-10-04 15:14       ` Michael Bernhard
2011-10-04 15:29         ` Gilles Chanteperdrix
2011-10-05 17:07           ` Michael Bernhard
2011-10-05 17:35             ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E8981F9.9090105@domain.hid \
    --to=michael.bernhard@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.