infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 3 of 3

Thread: How to create stack overflow/underflow exception ?

  1. #1
    New Member New Member jani is on a distinguished road
    Join Date
    Dec 2016
    Posts
    24
    Points
    46.875

    How to create stack overflow/underflow exception ?

    I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.

    Consider stack starting address 0x5000 0000. The stack size is 0x2000.

    If I take current stack pointer minus 0x2000, will that create stack exception? If yes, what might be 'C' or assembly language code that will achieve this?

    My thought is if I subtract negative 0x2000 from current stack pointer or add 0x2000 to current stack pointer, I'll be outside stack and stack exception will occur ?

    I need to set program counter to illegal address, i.e. 0x00FF FFFC. Can this be done with assembly language instructions?
    If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running.

  2. #2
    New Member New Member jani is on a distinguished road
    Join Date
    Dec 2016
    Posts
    24
    Points
    46.875
    Please disregard following text from my original post:

    "I need to set program counter to illegal address, i.e. 0x00FF FFFC. Can this be done with assembly language instructions?
    If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running."

  3. #3
    Beginner Beginner jonnyx is on a distinguished road
    Join Date
    Jul 2018
    Posts
    5
    Points
    70
    Just allocate uint32_t array[size>maximally available size on stack] = {0};
    this will cause a stack overflow -> just look at the assembly instructions during debugging and you will see the assembly commands causing this.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.