plz allow me to explain more.

"Why register-stack/memory-stack upside down is bad" is a bit complicated.
So...this is a test and result for explaining bug. 

This is a sample code and its result on 2.6.21-rc3.
Note: base address of memory'stack can be randomly change.

== sample code ==
[EMAIL PROTECTED] ~]$ cat sample.c
#include <stdio.h>

void do_print(int num)
{
        if (num == 0)
                return;
        printf("%d\n",num);
        do_print(num - 1);
}

int main(int argc, char *argv[])
{
        do_print(10000);
        return 0;
}

== before ulimit ==
[EMAIL PROTECTED] ~]$ uname -a
Linux drpq 2.6.21-rc3 #3 SMP Fri Mar 16 11:57:47 JST 2007 ia64 ia64 ia64 
GNU/Linux
[EMAIL PROTECTED] ~]$ ulimit -s
8192
[EMAIL PROTECTED] ~]$ ulimit -s -H
unlimited
[EMAIL PROTECTED] ~]$ ./sample
10000
9999
....<snip>
1
[EMAIL PROTECTED] ~]$
== after ulimit -s 8192 ==

[EMAIL PROTECTED] ~]$ ulimit -s
8192
[EMAIL PROTECTED] ~]$ ulimit -s -H
8192
[EMAIL PROTECTED] ~]$ ./sample  
10000
9999
....<snip>

9612
9611
9610
9609
9608
Segmentation fault

[EMAIL PROTECTED] ~]$ ./sample   (when I'm lucky)
10000
9999
....<snip>
1
[EMAIL PROTECTED] ~]$
=====================================

This number 9608 is too short to use up all stack. The reason of this is 
"ulimit -s + memory stack randomization + register-stack-expansion" is buggy.
The program can only use one page for register stack if unlucky.
My patch will fix this case.

-Kame








-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to