On 4/17/2021 7:34 PM, Ben Bacarisse wrote:
> olcott <No...@NoWhere.com> writes:
>
>> If a function X() is called by function Y() twice in sequence from the
>> same machine address of Y() with the same parameters to X() and the
>> execution trace shows no conditional branch instructions in Y() or
>> function call returns in X() then the function call from Y() to X() is
>> infinitely recursive unless X() stops it.
>
> You mean like this:
>
> 0x000055555555517d <main+0>: endbr64
> 0x0000555555555181 <main+4>: push %rbp
> 0x0000555555555182 <main+5>: mov %rsp,%rbp
> 0x0000555555555185 <main+8>: callq 0x555555555129 <Y>
> 0x0000555555555129 <Y+0>: endbr64
> 0x000055555555512d <Y+4>: push %rbp
> 0x000055555555512e <Y+5>: mov %rsp,%rbp
> 0x0000555555555131 <Y+8>: mov 0x2f15(%rip),%eax
> 0x0000555555555137 <Y+14>: lea 0x1(%rax),%edx
> 0x000055555555513a <Y+17>: mov %edx,0x2f0c(%rip)
> 0x0000555555555140 <Y+23>: cltq
> 0x0000555555555142 <Y+25>: lea 0x0(,%rax,8),%rdx
> 0x000055555555514a <Y+33>: lea 0x2ecf(%rip),%rax
> 0x0000555555555151 <Y+40>: mov (%rdx,%rax,1),%rax
> 0x0000555555555155 <Y+44>: callq *%rax
> 0x000055555555515c <X+0>: endbr64
> 0x0000555555555160 <X+4>: push %rbp
> 0x0000555555555161 <X+5>: mov %rsp,%rbp
> 0x0000555555555164 <X+8>: callq 0x555555555129 <Y>
> 0x0000555555555129 <Y+0>: endbr64
> 0x000055555555512d <Y+4>: push %rbp
> 0x000055555555512e <Y+5>: mov %rsp,%rbp
> 0x0000555555555131 <Y+8>: mov 0x2f15(%rip),%eax
> 0x0000555555555137 <Y+14>: lea 0x1(%rax),%edx
> 0x000055555555513a <Y+17>: mov %edx,0x2f0c(%rip)
> 0x0000555555555140 <Y+23>: cltq
> 0x0000555555555142 <Y+25>: lea 0x0(,%rax,8),%rdx
> 0x000055555555514a <Y+33>: lea 0x2ecf(%rip),%rax
> 0x0000555555555151 <Y+40>: mov (%rdx,%rax,1),%rax
> 0x0000555555555155 <Y+44>: callq *%rax
> 0x000055555555515c <X+0>: endbr64
> 0x0000555555555160 <X+4>: push %rbp
> 0x0000555555555161 <X+5>: mov %rsp,%rbp
> 0x0000555555555164 <X+8>: callq 0x555555555129 <Y>
> 0x0000555555555129 <Y+0>: endbr64
> 0x000055555555512d <Y+4>: push %rbp
> 0x000055555555512e <Y+5>: mov %rsp,%rbp
> 0x0000555555555131 <Y+8>: mov 0x2f15(%rip),%eax
> 0x0000555555555137 <Y+14>: lea 0x1(%rax),%edx
> 0x000055555555513a <Y+17>: mov %edx,0x2f0c(%rip)
> 0x0000555555555140 <Y+23>: cltq
> 0x0000555555555142 <Y+25>: lea 0x0(,%rax,8),%rdx
> 0x000055555555514a <Y+33>: lea 0x2ecf(%rip),%rax
> 0x0000555555555151 <Y+40>: mov (%rdx,%rax,1),%rax
> 0x0000555555555155 <Y+44>: callq *%rax
> 0x000055555555515c <X+0>: endbr64
> 0x0000555555555160 <X+4>: push %rbp
> 0x0000555555555161 <X+5>: mov %rsp,%rbp
> 0x0000555555555164 <X+8>: callq 0x555555555129 <Y>
> 0x0000555555555129 <Y+0>: endbr64
> 0x000055555555512d <Y+4>: push %rbp
> 0x000055555555512e <Y+5>: mov %rsp,%rbp
> 0x0000555555555131 <Y+8>: mov 0x2f15(%rip),%eax
> 0x0000555555555137 <Y+14>: lea 0x1(%rax),%edx
> 0x000055555555513a <Y+17>: mov %edx,0x2f0c(%rip)
> 0x0000555555555140 <Y+23>: cltq
> 0x0000555555555142 <Y+25>: lea 0x0(,%rax,8),%rdx
> 0x000055555555514a <Y+33>: lea 0x2ecf(%rip),%rax
> 0x0000555555555151 <Y+40>: mov (%rdx,%rax,1),%rax
> 0x0000555555555155 <Y+44>: callq *%rax
> 0x000055555555515c <X+0>: endbr64
> 0x0000555555555160 <X+4>: push %rbp
> 0x0000555555555161 <X+5>: mov %rsp,%rbp
> 0x0000555555555164 <X+8>: callq 0x555555555129 <Y>
> 0x0000555555555129 <Y+0>: endbr64
> 0x000055555555512d <Y+4>: push %rbp
> 0x000055555555512e <Y+5>: mov %rsp,%rbp
> 0x0000555555555131 <Y+8>: mov 0x2f15(%rip),%eax
> 0x0000555555555137 <Y+14>: lea 0x1(%rax),%edx
> 0x000055555555513a <Y+17>: mov %edx,0x2f0c(%rip)
> 0x0000555555555140 <Y+23>: cltq
> 0x0000555555555142 <Y+25>: lea 0x0(,%rax,8),%rdx
> 0x000055555555514a <Y+33>: lea 0x2ecf(%rip),%rax
> 0x0000555555555151 <Y+40>: mov (%rdx,%rax,1),%rax
> 0x0000555555555155 <Y+44>: callq *%rax
> 0x000055555555516e <Z+0>: endbr64
> 0x0000555555555172 <Z+4>: push %rbp
> 0x0000555555555173 <Z+5>: mov %rsp,%rbp
> 0x0000555555555176 <Z+8>: mov $0x1,%eax
> ...
>
> Note how X is called from Y+44 more than once with no branching or
> returns.
>
Lets simply assume x86 architecture and Intel syntax.
This is my latest revised infinite recursion halt deciding criteria:
If the execution trace of function X() called by function Y() shows:
(1) Function X() is called twice in sequence from the same machine
address of Y().
(2) With the same parameters to X().
(3) With no conditional branch or indexed jump instructions in Y().
(4) With no function call returns from X().
then the function call from Y() to X() is infinitely recursive unless
X() stops it.