On Fri, May 1, 2020 at 6:04 AM Thomas Koenig via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hello world,
>
> because the test case for PR 94788 requires -fsanitize=address to expose
> the double free, I have created a subdirectory under gfortran.dg
> where such test cases can go.
>
> I have tested this with
>
> make check-fortran RUNTESTFLAGS="asan.exp=*"
>
> and it works; with a compiler that introduces the double free bug
> into the test case, the result is as expected:
>
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
> -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
> -finline-functions  execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3 -g
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
> execution test
>
> So, any comments regarding style, functionality etc?  If not, I plan
> on committing this to trunk within the next couple of days.
>

I checked in this patch to fix:

https://gcc.gnu.org/pipermail/gcc-regression/2020-May/072549.html

FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)

-- 
H.J.
From 6abe1c3084798d3e5f32926c352643e557073e01 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 2 May 2020 12:46:44 -0700
Subject: [PATCH] gfortran: Get asan library from TEST_ALWAYS_FLAGS

Update gfortran_target_compile to get the newly built asan library from
TEST_ALWAYS_FLAGS to avoid:

/usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
/usr/bin/ld: cannot find -lasan
collect2: error: ld returned 1 exit status
compiler exited with status 1
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0  (test for excess errors)

	PR fortran/94788
	* lib/gfortran.exp (gfortran_target_compile): Get asan library
	from TEST_ALWAYS_FLAGS.
---
 gcc/testsuite/ChangeLog        | 6 ++++++
 gcc/testsuite/lib/gfortran.exp | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a9c72f982fe..b0c6f9a8cef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR fortran/94788
+	* lib/gfortran.exp (gfortran_target_compile): Get asan library
+	from TEST_ALWAYS_FLAGS.
+
 2020-05-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	PR fortran/94788
diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp
index 016d77ca4f8..fe99111788f 100644
--- a/gcc/testsuite/lib/gfortran.exp
+++ b/gcc/testsuite/lib/gfortran.exp
@@ -234,6 +234,7 @@ proc gfortran_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_GFORTRANFLAGS
     global GFORTRAN_UNDER_TEST
+    global TEST_ALWAYS_FLAGS
     global flags_to_postpone
     global board_info
 
@@ -242,6 +243,13 @@ proc gfortran_target_compile { source dest type options } {
 	lappend options "ldflags=${wrap_flags}"
     }
 
+    # TEST_ALWAYS_FLAGS are flags that should be passed to every
+    # compilation.  They are passed first to allow individual
+    # tests to override them.
+    if [info exists TEST_ALWAYS_FLAGS] {
+	set options [concat "{additional_flags=$TEST_ALWAYS_FLAGS}" $options]
+    }
+
     # bind_pic_locally adds -fpie/-fPIE flags to flags_to_postpone and it is
     # appended here to multilib_flags as it can be overridden by the latter
     # if it was added earlier. After the target_compile, multilib_flags is
-- 
2.26.2

Reply via email to