AnsweredAssumed Answered

Hard - to catch - fault

Question asked by Legrand.Thomas.001 on Jun 4, 2013
Latest reply on Aug 19, 2013 by Legrand.Thomas.001

Hello,

I have a kind of strange issue. When I really stress my system (it handles serial packets, get the right data, and send it via serial, I send thousands of messages without waiting for reply), in an unpredictable way, I sometimes get an invalid PC load usage fault of invalid state fault.

When I get an invalid PC load usage, the program counter is like 0x0 or 0x5, or sometimes it contains a ram address, but I don't have code in ram, and looking at the stack trace, I have the feeling there is a stack pointer corruption somewhere because some of the registers have flash address of branch code in them (and LR has weird stuff, obviously not flash code nor ram address).

Here are my stack traces :

****************************
HARD FAULT !

Stack = 0x20000660
Invalid PC load usage fault at
Program counter = 0x200082B0

Stack frame :
R0  = 0x400264B8
R1  = 0x20008318
R2  = 0x3C
R3  = 0x200082B0
R12 = 0x0
LR  = 0x8002417
PC  = 0x200082B0
PSR = 0x20008318

****************************

Or :

****************************
HARD FAULT !

Stack = 0x20000688
Invalid state usage fault at
Program counter = 0x20008270

Stack frame :
R0  = 0x20008288
R1  = 0x20008EA8
R2  = 0x3C
R3  = 0x200082B0
R12 = 0x0
LR  = 0x20008270
PC  = 0x20008270
PSR = 0x20000200

****************************

Or again:

****************************
HARD FAULT !

Stack = 0x20000670
Invalid PC load usage fault at
Program counter = 0x1

Stack frame :
R0  = 0x0
R1  = 0x80023D7
R2  = 0x8003B26
R3  = 0x21000200
R12 = 0x0
LR  = 0x8003279
PC  = 0x1
PSR = 0x200082B0

****************************

The problem seems to happen (tried to track it down but it's very hard) on the service call interrupt exit after a malloc call (but there is like 10000 malloc calls without problem first).

My process stacks are far from full (half empty at min), I have 8k of system stack. The hard fault happens with user stack, but again, seems to trigger when popping rgisters at service call exit.

Spent about 10 hours trying to fix this, but no luck so far, do youguys have any advice for me?

Thomas.

Outcomes