Patchwork Fix tst-setcontext9 for optimized small stacks.

login
register
mail settings
Submitter Andreas Schwab
Date Sept. 27, 2018, 9:16 a.m.
Message ID <mvm5zyr8fm6.fsf@suse.de>
Download mbox | patch
Permalink /patch/29561/
State New
Headers show

Comments

Andreas Schwab - Sept. 27, 2018, 9:16 a.m.
On Sep 26 2018, Carlos O'Donell <carlos@redhat.com> wrote:

> Does it run out of stack?

Definitely.

Andreas.

	[BZ #23717]
	* stdlib/tst-setcontext9.c (f1a): Make st2 static.
	(do_test): Make st1 static.
---
 stdlib/tst-setcontext9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Florian Weimer - Sept. 27, 2018, 10:06 a.m.
* Andreas Schwab:

> On Sep 26 2018, Carlos O'Donell <carlos@redhat.com> wrote:
>
>> Does it run out of stack?
>
> Definitely.
>
> Andreas.
>
> 	[BZ #23717]
> 	* stdlib/tst-setcontext9.c (f1a): Make st2 static.
> 	(do_test): Make st1 static.

I'm happy to report that this fixes powerpc64le for me.  The change
looks reasonable.  Maybe you coulkd mention somewhere (in the ChangeLog
entry or the commit message) that this is to reduce stack usage and
avoid stack overflows.

Thanks,
Florian
Carlos O'Donell - Sept. 27, 2018, 6:26 p.m.
On 9/27/18 5:16 AM, Andreas Schwab wrote:
> On Sep 26 2018, Carlos O'Donell <carlos@redhat.com> wrote:
> 
>> Does it run out of stack?
> 
> Definitely.

Thanks for fixing this. I was a dummy.

> Andreas.
> 
> 	[BZ #23717]
> 	* stdlib/tst-setcontext9.c (f1a): Make st2 static.
> 	(do_test): Make st1 static.
> ---
>  stdlib/tst-setcontext9.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
> index db8355766c..009928235d 100644
> --- a/stdlib/tst-setcontext9.c
> +++ b/stdlib/tst-setcontext9.c
> @@ -58,7 +58,7 @@ f1b (void)
>  static void
>  f1a (void)
>  {
> -  char st2[32768];
> +  static char st2[32768];
>    puts ("start f1a");
>    if (getcontext (&ctx[2]) != 0)
>      {
> @@ -93,7 +93,7 @@ f1a (void)
>  static int
>  do_test (void)
>  {
> -  char st1[32768];
> +  static char st1[32768];
>    puts ("making contexts");
>    if (getcontext (&ctx[0]) != 0)
>      {
>

Patch

diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index db8355766c..009928235d 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -58,7 +58,7 @@  f1b (void)
 static void
 f1a (void)
 {
-  char st2[32768];
+  static char st2[32768];
   puts ("start f1a");
   if (getcontext (&ctx[2]) != 0)
     {
@@ -93,7 +93,7 @@  f1a (void)
 static int
 do_test (void)
 {
-  char st1[32768];
+  static char st1[32768];
   puts ("making contexts");
   if (getcontext (&ctx[0]) != 0)
     {