Re: [PATCH 7/7] Allow unwind_stack() to return ra for leaf function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue,  1 Aug 2006 11:27:17 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote:
> Since get_frame_info() is more robust, unwind_stack() can
> returns ra value for leaf functions.

I think it is still fragile.  The get_frame_info() might misdetect
nested function as leaf.  For example, I can craft this code:

int nestfunc(int arg)
{
	if (arg)
		return 0;
	func();
	return 1;
}

	.set noreorder
nestfunc:
	beqz	a0, 1f
	 nop
	jr	ra
	 move	v0, zero
1:
	addiu	sp, sp, -24
	sw	ra, 16(sp)
	jal	func
	 nop
	lw	ra, 16(sp)
	li	v0, 1
	jr	ra
	 addiu	sp, sp, 24

(Though it seems a bit artificial, who believe gcc never do it same?)

The get_frame_info() will think this is a leaf.  With your patch,
unwind_stack() might fall into endless loop at worst (if the "func"
was leaf and an exception happened in the "func").

I think you should ensure unwind_stack() never use regs->regs[31]
elsewhere than top of the stack.

---
Atsushi Nemoto


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux