Bug #509

corrupted call stack

Added by DPalme about 2 years ago. Updated about 2 years ago.

Status:NewStart date:09/27/2012
Priority:ImmediateDue date:
Assignee:rrauch% Done:

0%

Category:-Spent time:-
Target version:-
Definition of Done:
Milestones:

Description

Enabling stack checking for eCos on the µBlaze CPU runs immediately into an assertion, because the reserved area on top/bottom of the stack is overwritten.

Used toolchain: microblazeel-unknown-linux-gnu-gcc

We analyzed the generated assembler code and this looks strange:

Cyg_Scheduler::thread_entry(Cyg_Thread*):
8806dad8: addik r1, r1, -32
8806dadc: swi r15, r1, 0
8806dae0: swi r19, r1, 28
8806dae4: addk r19, r1, r0
8806dae8: swi r5, r19, 36
8806daec: swi r6, r19, 40
8806daf0: imm -1
8806daf4: brlid r15, -5064 // 0x8806c72c <Cyg_Scheduler_Base::clear_need_reschedule()>

From our understanding the compiler reserves 32 bytes on the stack "addik r1, r1, -32". But some instructions later the stack is used on offset 36 "swi r5, r19, 36" and 40 "swi r5, r19, 40". This results in a corrupted stack, which is detected by eCos stack_check() function.

History

#1 Updated by DPalme about 2 years ago

  • Assignee set to rrauch

#2 Updated by rrauch about 2 years ago

  • Tracker changed from Description to Bug

Also available in: Atom PDF