[Bug c++/113531] [14 Regression] AddressSanitizer: stack-use-after-scope when iterating over initializer list since r14-1500-g4d935f52b0d5c0

2024-02-01 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113531

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Priority|P3  |P1
 Status|ASSIGNED|RESOLVED

--- Comment #4 from Jakub Jelinek  ---
Fixed.

[Bug c++/113531] [14 Regression] AddressSanitizer: stack-use-after-scope when iterating over initializer list since r14-1500-g4d935f52b0d5c0

2024-02-01 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113531

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:ceb242f5302027c44a7dca86c344863004b6fec4

commit r14-8681-gceb242f5302027c44a7dca86c344863004b6fec4
Author: Jakub Jelinek 
Date:   Thu Feb 1 09:16:57 2024 +0100

gimple-low: Remove .ASAN_MARK calls on TREE_STATIC variables [PR113531]

Since the r14-1500-g4d935f52b0d5c0 commit we promote an initializer_list
backing array to static storage where appropriate, but this happens after
we decided to add it to asan_poisoned_variables.  As a result we add
unpoison/poison for it to the gimple.  But then sanopt removes the
unpoison.
So the second time we call the function and want to load from the array
asan
still considers it poisoned.

The following patch fixes it by removing the .ASAN_MARK internal calls
during gimple lowering if they refer to TREE_STATIC vars.

2024-02-01  Jakub Jelinek  
Jason Merrill  

PR c++/113531
* gimple-low.cc (lower_stmt): Remove .ASAN_MARK calls
on variables which were promoted to TREE_STATIC.

* g++.dg/asan/initlist1.C: New test.

Co-authored-by: Jason Merrill 

[Bug c++/113531] [14 Regression] AddressSanitizer: stack-use-after-scope when iterating over initializer list since r14-1500-g4d935f52b0d5c0

2024-01-30 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113531

--- Comment #2 from Jason Merrill  ---
Reduced:

#include 

void f(int) { }

void g()
{
  for (auto i : { 1, 2, 3 })
f (i);
  f(42);
}

int main()
{
  g();
  g();
}

[Bug c++/113531] [14 Regression] AddressSanitizer: stack-use-after-scope when iterating over initializer list since r14-1500-g4d935f52b0d5c0

2024-01-30 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113531

Jason Merrill  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org
   Last reconfirmed||2024-01-30
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
 Status|UNCONFIRMED |ASSIGNED
 Ever confirmed|0   |1

[Bug c++/113531] [14 Regression] AddressSanitizer: stack-use-after-scope when iterating over initializer list since r14-1500-g4d935f52b0d5c0

2024-01-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113531

--- Comment #1 from Andrew Pinski  ---
It would be useful to get a reduced testcase without the use of the Catch2Main
library.