Most common Errors in embedded systems

Errors

____________________________________________________________________________________________________

 

Stack overflow

A stack overflow error can occur due to excessive memory usage on the call stack, which is where information is stored relating to the active subroutines in the program. The call stack has a limited amount of memory available to it.

                 Typically, when a stack overflow error occurs, the program crashes and can either freeze or close the program. Any unsaved data or work is lost. 

Causes of Stackoverflow:

1). The most common cause of stack overflow is excessively deep or infinite recursion. As we know the procedure of function calling, each time we call any function(subroutine), its returning address, parameters, etc. are stored in stack(specific area of RAM). So as the function calling increases, its data also increased and at the end memory of stack is full and after that stack overflow occurs.

 

 2). The other major cause of a stack overflow results from an attempt to allocate more memory on the stack than will fit, for example by creating local array variables that are too large. For this reason some authors recommend that arrays larger than a few kilobytes should be allocated dynamically instead of as a local variable.

 

Segmentation fault

A segmentation fault or access violation occurs when a program attempts to access a memory location that is not exist, or attempts to access a memory location in a way that is not allowed.

 

Causes of segmentation fault:

  • it arise primarily due to errors in use of pointers for virtual memory addressing, particularly illegal access.
  • De-referencing NULL pointers – this is special-cased by memory management hardware.
  • Attempting to access a nonexistent memory address (outside process’s address space).
  • Attempting to access memory the program does not have rights to (such as kernel structures in process context).
  • Attempting to write read-only memory (such as code segment).

Memory leak

In computer science, a memory leak occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released.

                 Memory is allocated but not released eventually causing the system to page virtual memory to the hard drive which slowing the application or crashing the application when than the computer memory resource limits are reached. The system may stop working as these limits are approached.

 

Fragmentation or Memory Corruption

Memory when altered without an explicit assignment due to the inadvertent and unexpected altering of data held in memory or the altering of a pointer to a specific place in memory.

Example 1:

Example 2:

If you like this Article, then don’t forget to Click on Social likes buttons.