On Fri, 2025-01-24 at 17:25 +0100, Jakub Jelinek wrote:
> On Thu, Jan 09, 2025 at 01:15:30AM +0100, Ilya Leoshkevich wrote:
> > Bootstrapped and regtested on x86_64-redhat-linux.  Ok for master?
> > 
> > 
> > 
> > The FakeStack flag is not zeroed out when can_store_by_pieces()
> > returns false.  Over time, this causes FakeStack::Allocate() to
> > perform
> > the maximum number of loop iterations, significantly slowing down
> > the
> > instrumented program.
> 
> Took me a while to construct a testcase where it makes a difference,
> but e.g.
> void foo (int *, int *, int *, int *, int *, int *);
> 
> int
> bar (void)
> {
>   int a[3], b[26];
>   foo (a, b, 0, 0, 0, 0);
>   return 0;
> }
> 
> int
> baz (void)
> {
>   int a[3], b[26], c[371], d[12], e[257], f[5];
>   foo (a, b, c, d, e, f);
>   return 0;
> }
> shows it on s390x with -O2 -fsanitize=address on bar but not baz (on
> x86_64
> not on either).
> 
> > gcc/ChangeLog:
> > 
> >  * asan.cc (asan_emit_stack_protection): Always zero the flag
> >  unless it is cleared by the __asan_stack_free_N() libcall.
> > 
> > Signed-off-by: Ilya Leoshkevich <i...@linux.ibm.com>
> > ---
> >  gcc/asan.cc | 30 ++++++++++++++++++------------
> >  1 file changed, 18 insertions(+), 12 deletions(-)

[...]

> Ok for trunk with that nit fixed.
> 
>  Jakub

Thank you for the review!
I have fixed the style and committed this.

Would it be okay to backport this to gcc-13 and gcc-14?
Bootstrap and regtest pass on x86_64-redhat-linux.

Reply via email to