R
R
RokkerRuslan2014-05-06 13:49:58
linux
RokkerRuslan, 2014-05-06 13:49:58

What are the causes of a segmentation fault?

I googled a lot of reasons, but I can’t fit one to the problem.
Let's say we have a code:

.globl main
.text
main:
  addl	$4, %esp

Yes, esp does not point to the address that it pointed to before the first instruction was executed. But after all for each process registers are independent? Esp is not used anywhere.
There is an assumption that there is a call to main, but there is no return from main, and if the value of the stack pointer is restored, then the collapse will not occur.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2014-05-06
@RokkerRuslan

There are no problems in this code. Add
1: jmp 1b
to the end so as not to fall into nowhere and everything will loop perfectly without segfaults.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question