2010-05-04 12:14:17     Faulty compiles with bfin-uclinux-gcc

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

2010-05-04 12:14:17     Faulty compiles with bfin-uclinux-gcc

Morten Kvistgaard (DENMARK)

Message: 89117   


Hello there,


I've been working with uClinux for a few months now and I've run into a strange problem. My compiles with bfin-uclinux-gcc seems to be broken or something. The compiler doesn't give any warnings or errors, but when I run the program all sorts of errors occur. Like eg. NULL pointer errors, data misaligns, CPLB errors etc. And I can also make it hang (for no apparent reason).


The stack traces differs somewhat, but it often pinpoints the error to a printf, fflush, putc, etc. It doesn’t make any sence really.




If I reorder the code, the program will break somewhere else and give a new stack trace. (I first had all my code in main. Now it’s divided into several functions.)




I’ve attached a stack trace and the userspace code. The current stack trace is somewhat funny actually, seeing that none of the traces are in my program (UnitTestMk3Mem).


The program is a unit test meant for one of our kernel modules. At this point it just opens up a normal file and it still breaks.




Currently the code that breaks is:




/* Memory stress */


printf("Dynamic Memory stress test...\n");


int fds[1000]; /* max 1000 open files (the real number is actually o. 8k. Doesn't seem to work though) */


for (n = 0; n < 100; n++)




for (r = 0; r < 1000; r++)




fds[r] = open(memfile, O_RDWR);


if (fds[r] <= 0)




printf("Opened: %d\n", r);


perror("open FAILED!");






/* ioctl function removed */




for (r = 0; r < 1000; r++)








printf("."); /* status update */












And it gives a NULL pointer error at fflush(stdout) …. Bzzz


memfile is “./tmp” btw.




I’m using a BF526 ezbrd with a uClinux-svn-trunk-9367 (standard setup mostly) and the newest svn toolchain. I’ve also tried with the newest mature uClinux 2009R1.1 and the mature toolchain. No difference.


After several days with this problem I’m all out of ideas. Are there some trick that I should be aware of? Like “the code in a single file, can’t be too long” or “You can’t allocate 4k variables without using malloc” or “After 100k open/closes it is meant to break” or “Don’t open more than 5 files, without closing some” or something like that?


PS. I’m a SW person. I’m mostly used to PCs.




Mem m. flush.txt




2010-05-04 13:49:20     Re: Faulty compiles with bfin-uclinux-gcc

Mike Frysinger (UNITED STATES)

Message: 89121   


are you sure you didnt blow your stack ?  please read the documentation:





2010-05-05 03:58:25     Re: Faulty compiles with bfin-uclinux-gcc

Morten Kvistgaard (DENMARK)

Message: 89148   


A stack overflow!


I acutally thought that the stack size was calculated at compile time.  How naive. (Foolish high level programmers)




Thank you, very much