2011-01-21 06:11:41     SEGV when explicitly linking Xenomai app with libpthread

Document created by Aaronwu Employee on Oct 16, 2013
Version 1Show Document
  • View in full screen mode

2011-01-21 06:11:41     SEGV when explicitly linking Xenomai app with libpthread

Kolja Waschk (GERMANY)

Message: 97601   




I'm facing a strange problem when using "proper" POSIX cflags and ldflags for creating a Xenomai user space application. I've reduced the compiler flags to reproduce the problem to the bare minimum in the following example.


Given the example code "a.c"


int main()


    return 0;



Compile with


bfin-linux-uclibc-gcc  -L/opt/uClinux/blackfin-linux-dist/staging/usr/lib -lxenomai -lpthread_rt -lpthread a.c




And then load it on a BF537-STAMP via gdbserver. As soon as it is started with gdb from the development host, the gdbserver/a.out process will terminate with NULL pointer access exception. Even before main() is reached...


Process ./a.out created; pid = 534

Listening on port 2222

Remote debugging from host

NULL pointer access

Deferred Exception context


COMM=a.out PID=534  CPU=0

TEXT = 0x00ca7000-0x00ca7758        DATA = 0x015f0758-0x015f08bc

BSS = 0x015f08bc-0x00c80000  USER-STACK = 0x00c9fe60


return address: [0x01636f10]; contents of:

0x01636ef0:  e42f  0015  0c07  1405  3047  67f8  e628  0015

0x01636f00:  320e  3044  300d  3014  e50a  003a  5ea2  9153

0x01636f10: [9159] ac5b  0061  0c07  1404  6000  e628  0015

0x01636f20:  e801  0000  05a4  0010  e51a  0016  05f4  e800


ADSP-BF537-0.3 533(MHz CCLK) 133(MHz SCLK) (mpu off)

Linux version (kawk@fee) (gcc version 4.3.5 (ADI-2010R1-RC4) ) #48 Fri Jan 21 09:39:29 CET 2011


SEQUENCER STATUS:        Not tainted

SEQSTAT: 00060027  IPEND: 0008  IMASK: ffff  SYSCFG: 0006

  EXCAUSE   : 0x27

  physical IVG3 asserted : <0xffa0076c> { _trap + 0x0 }

RETE: <0x00000000> /* Maybe null pointer? */

RETN: <0x01622000> /* kernel dynamic memory */

RETX: <0x00000480> /* Maybe fixed code section */

RETS: <0x01636eda> [ /lib/libpthread.so.0 + 0x6eda ]

PC  : <0x01636f10> [ /lib/libpthread.so.0 + 0x6f10 ]

DCPLB_FAULT_ADDR: <0x00000000> /* Maybe null pointer? */

ICPLB_FAULT_ADDR: <0x01636f10> [ /lib/libpthread.so.0 + 0x6f10 ]




The following gdb commands were issued:




file a.out

target remote

break main





The problem does not occur if I omit the "-lpthread" library from the above gcc command line. libpthread will be silently added by the linker (probably because libxenomai or libpthread_rt somehow reference it) and everything runs fine.


This is not a real problem because it can be avoided, but the default POSIX LDFLAGS for linking Xenomai apps contain exactly that library options and as such would trigger the problem. So I thought I'd report it because it might actually point to some problem with the linker or loader?


I'm using 2010R1-RC5 with tools 2010R1-RC4 and Xenomai as a drop-in replacement for the 2.5.3 that comes with the 2010R1-RC5.






2011-01-27 07:26:52     Re: SEGV when explicitly linking Xenomai app with libpthread

Kolja Waschk (GERMANY)

Message: 97722   


This turned out to be a problem in Xenomai startup, see mail.gna.org/public/xenomai-help/2011-01/msg00241.html