/
Understanding What Causes SEGV in an Application

Understanding What Causes SEGV in an Application

If a user-space application terminates with SEGV, this means, as it is always the case in Linux, that the application did something that triggered an exception to the Cortex-M processor core. The most likely causes are:

  • You built your application for a processor architecture other than Cortex-M, which causes an "Unsupported instruction" exception.

  • Your application makes an attempt to access an address outside of the Cortex-M address space.

  • Your application makes an attempt to access unaligned data.

To understand what is causing an exception, do the following:

  • Enable CONFIG_DEBUG_USER in the kernel configuration. From your project directory, bring up the kernel configuration interface by running make kmenuconfig. Go to Kernel hacking and enable Verbose user fault messages.

  • In U-boot, add user_debug=8 to bootargs.

  • Having done the above, rebuild your Linux project, bring it up on the target and re-run your application. When the application fails with SEGV, there should be some informational messages on the system console indicating the cause of the fault.

Related content

Understanding What Causes SEGV in an Application
Understanding What Causes SEGV in an Application
More like this
Remote Debugging with GDB (uClinux)
Remote Debugging with GDB (uClinux)
More like this
Debugging with Eclipse
Debugging with Eclipse
More like this
Remote Debugging with GDB
Remote Debugging with GDB
More like this
Setting the Stack Size for a User-Space Application
Setting the Stack Size for a User-Space Application
More like this
Remote Debugging with GDB
Remote Debugging with GDB
More like this