public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
@ 2015-03-28  0:02 Dominique Dhumieres
  2015-03-28  0:33 ` Steve Kargl
  2015-03-29 16:25 ` Steve Kargl
  0 siblings, 2 replies; 11+ messages in thread
From: Dominique Dhumieres @ 2015-03-28  0:02 UTC (permalink / raw)
  To: sgk; +Cc: gcc-patches, fortran

Steve,

AFAICT your test succeeds without your patch and does not test that the ICE
reported by FX is gone (indeed it is with your patch).

TIA

Dominique

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-28  0:02 [PATCH] fortran/65429 -- don't dereference a null pointer Dominique Dhumieres
@ 2015-03-28  0:33 ` Steve Kargl
  2015-03-28 11:42   ` Dominique d'Humières
  2015-03-29 16:25 ` Steve Kargl
  1 sibling, 1 reply; 11+ messages in thread
From: Steve Kargl @ 2015-03-28  0:33 UTC (permalink / raw)
  To: Dominique Dhumieres; +Cc: gcc-patches, fortran

On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> 
> AFAICT your test succeeds without your patch and does not test that the ICE
> reported by FX is gone (indeed it is with your patch).
> 

Yeah, I thought about that, but did not pursue it, yet.
It is a zero-size string issue because FX's initialization
is empty.  I'll play a little bit tomorrow with the
testcase case.

-- 
Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-28  0:33 ` Steve Kargl
@ 2015-03-28 11:42   ` Dominique d'Humières
  2015-03-28 14:50     ` Steve Kargl
  0 siblings, 1 reply; 11+ messages in thread
From: Dominique d'Humières @ 2015-03-28 11:42 UTC (permalink / raw)
  To: Steve Kargl; +Cc: gcc-patches, fortran

See also my comment 2 in pr65429.

Cheers,

Dominique

> Le 28 mars 2015 à 01:33, Steve Kargl <sgk@troutmask.apl.washington.edu> a écrit :
> 
> On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
>> 
>> AFAICT your test succeeds without your patch and does not test that the ICE
>> reported by FX is gone (indeed it is with your patch).
>> 
> 
> Yeah, I thought about that, but did not pursue it, yet.
> It is a zero-size string issue because FX's initialization
> is empty.  I'll play a little bit tomorrow with the
> testcase case.
> 
> -- 
> Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-28 11:42   ` Dominique d'Humières
@ 2015-03-28 14:50     ` Steve Kargl
  2015-03-28 15:17       ` Dominique d'Humières
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Kargl @ 2015-03-28 14:50 UTC (permalink / raw)
  To: Dominique d'Humi?res; +Cc: gcc-patches, fortran

>> 28 mars 2015, 01:33, Steve Kargl <sgk@troutmask.apl.washington.edu>:
>> 
>> On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
>>> 
>>> AFAICT your test succeeds without your patch and does not test that the ICE
>>> reported by FX is gone (indeed it is with your patch).
>>> 
>> 
>> Yeah, I thought about that, but did not pursue it, yet.
>> It is a zero-size string issue because FX's initialization
>> is empty.  I'll play a little bit tomorrow with the
>> testcase case.
> On Sat, Mar 28, 2015 at 12:42:29PM +0100, Dominique d'Humi?res wrote:
> See also my comment 2 in pr65429.
> 
> Cheers,
> 
> Dominique

Can one do anything useful with a zero-sized array
of strings where the length of a non-existent
element of the array is nonzero?

-- 
Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-28 14:50     ` Steve Kargl
@ 2015-03-28 15:17       ` Dominique d'Humières
  0 siblings, 0 replies; 11+ messages in thread
From: Dominique d'Humières @ 2015-03-28 15:17 UTC (permalink / raw)
  To: Steve Kargl; +Cc: gcc-patches, fortran


> Le 28 mars 2015 à 15:50, Steve Kargl <sgk@troutmask.apl.washington.edu> a écrit :
> 
> Can one do anything useful with a zero-sized array
> of strings where the length of a non-existent
> element of the array is nonzero?

The only answer I can give is that the users’ imagination is unbounded!

Dominique

> -- 
> Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-28  0:02 [PATCH] fortran/65429 -- don't dereference a null pointer Dominique Dhumieres
  2015-03-28  0:33 ` Steve Kargl
@ 2015-03-29 16:25 ` Steve Kargl
  2015-03-31 17:17   ` Jerry DeLisle
  1 sibling, 1 reply; 11+ messages in thread
From: Steve Kargl @ 2015-03-29 16:25 UTC (permalink / raw)
  To: Dominique Dhumieres; +Cc: gcc-patches, fortran

On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> 
> AFAICT your test succeeds without your patch and does not test that the ICE
> reported by FX is gone (indeed it is with your patch).
> 

New patch and testcase.  The ChangeLog entries are in the 
original email.  Built and tested on x86_64-*-freebsd.
OK, now?

-- 
Steve


Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 220943)
+++ gcc/fortran/decl.c	(working copy)
@@ -1404,9 +1404,7 @@ add_init_expr_to_sym (const char *name, 
 		    }
 		  else if (init->expr_type == EXPR_ARRAY)
 		    {
-		      gfc_constructor *c;
-		      c = gfc_constructor_first (init->value.constructor);
-		      clen = c->expr->value.character.length;
+		      clen = mpz_get_si (init->ts.u.cl->length->value.integer);
 		      sym->ts.u.cl->length
 				= gfc_get_int_expr (gfc_default_integer_kind,
 						    NULL, clen);
Index: gcc/testsuite/gfortran.dg/pr65429.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr65429.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr65429.f90	(working copy)
@@ -0,0 +1,19 @@
+! { dg-do run }
+! PR fortran/65429
+program foo
+
+   implicit none
+
+   character(*), parameter :: s(*) = [ character(5) :: 'abcde', 'fghij' ]
+   character(*), parameter :: t(*) = [ character(31) :: ]
+   character(*), parameter :: u(*) = [ 'qwerty', 'asdfgh', 'zxcvbn']
+   character(*), parameter :: v(*) = ['','']
+
+   if ((size(s) /= 2).or.(len(s)/=5)) call abort
+   if ((size(t) /= 0).or.(len(t)/=31)) call abort
+   if ((size(u) /= 3).or.(len(u)/=6)) call abort
+   if ((size(v) /= 2).or.(len(v)/=0)) call abort
+   if ((s(1)/='abcde').or.(s(2)/='fghij')) call abort
+   if ((u(1)/='qwerty').or.(u(2)/='asdfgh').or.(u(3)/='zxcvbn')) call abort
+
+end program foo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-29 16:25 ` Steve Kargl
@ 2015-03-31 17:17   ` Jerry DeLisle
  2015-04-07 19:59     ` Steve Kargl
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry DeLisle @ 2015-03-31 17:17 UTC (permalink / raw)
  To: Steve Kargl, Dominique Dhumieres; +Cc: gcc-patches, fortran

On 03/29/2015 09:25 AM, Steve Kargl wrote:
> On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
>>
>> AFAICT your test succeeds without your patch and does not test that the ICE
>> reported by FX is gone (indeed it is with your patch).
>>
>
> New patch and testcase.  The ChangeLog entries are in the
> original email.  Built and tested on x86_64-*-freebsd.
> OK, now?
>

OK Steve.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-31 17:17   ` Jerry DeLisle
@ 2015-04-07 19:59     ` Steve Kargl
  2015-04-22 23:18       ` Steve Kargl
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Kargl @ 2015-04-07 19:59 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: Dominique Dhumieres, gcc-patches, fortran

On Tue, Mar 31, 2015 at 10:17:14AM -0700, Jerry DeLisle wrote:
> On 03/29/2015 09:25 AM, Steve Kargl wrote:
> > On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> >>
> >> AFAICT your test succeeds without your patch and does not test that the ICE
> >> reported by FX is gone (indeed it is with your patch).
> >>
> >
> > New patch and testcase.  The ChangeLog entries are in the
> > original email.  Built and tested on x86_64-*-freebsd.
> > OK, now?
> >
> 
> OK Steve.

I just checked and this is not a regression with respect
to 4.6, 4.7. 4.8, or 4.9.  As 5.0 is coming soon, I'll
for stage 1 to commit.

-- 
Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-04-07 19:59     ` Steve Kargl
@ 2015-04-22 23:18       ` Steve Kargl
  0 siblings, 0 replies; 11+ messages in thread
From: Steve Kargl @ 2015-04-22 23:18 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: Dominique Dhumieres, gcc-patches, fortran

On Tue, Apr 07, 2015 at 12:59:20PM -0700, Steve Kargl wrote:
> On Tue, Mar 31, 2015 at 10:17:14AM -0700, Jerry DeLisle wrote:
> > On 03/29/2015 09:25 AM, Steve Kargl wrote:
> > > On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> > >>
> > >> AFAICT your test succeeds without your patch and does not test that the ICE
> > >> reported by FX is gone (indeed it is with your patch).
> > >>
> > >
> > > New patch and testcase.  The ChangeLog entries are in the
> > > original email.  Built and tested on x86_64-*-freebsd.
> > > OK, now?
> > >
> > 
> > OK Steve.
> 
> I just checked and this is not a regression with respect
> to 4.6, 4.7. 4.8, or 4.9.  As 5.0 is coming soon, I'll
> for stage 1 to commit.
> 

Fixed with the following

r222342 trunk
r222343 5.1 branch

-- 
Steve

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fortran/65429 -- don't dereference a null pointer
  2015-03-27 22:47 Steve Kargl
@ 2015-03-27 23:50 ` Tobias Burnus
  0 siblings, 0 replies; 11+ messages in thread
From: Tobias Burnus @ 2015-03-27 23:50 UTC (permalink / raw)
  To: Steve Kargl, fortran, gcc-patches

Steve Kargl wrote:
> The following patch avoids the dereferencing of
> a null pointer, which led to an ICE.  The patch
> here is a slight variation on the patch submitted
> by drikosev at otenet dot gr.  The testcase is a
> slight variation on the code submitted by FX.
>
> Built and regression tested on x86_64-*-freebsd.
> OK to commit?

OK. However, could you additionally add "if (len(s) /= 5) call abort" to 
the test, just to make sure. (It works, I tried it :-)

Thanks for the patch!

Tobias

> 2015-03-27  Steven G. Kargl  <kargl@gcc.gnu.org>
>
> 	PR fortran/65429
> 	* decl.c (add_init_expr_to_sym): Do not dereference a null pointer.
>
> 2015-03-27  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>      PR fortran/65429
> 	* pr65429.f90: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] fortran/65429 -- don't dereference a null pointer
@ 2015-03-27 22:47 Steve Kargl
  2015-03-27 23:50 ` Tobias Burnus
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Kargl @ 2015-03-27 22:47 UTC (permalink / raw)
  To: fortran, gcc-patches

The following patch avoids the dereferencing of
a null pointer, which led to an ICE.  The patch
here is a slight variation on the patch submitted
by drikosev at otenet dot gr.  The testcase is a
slight variation on the code submitted by FX.

Built and regression tested on x86_64-*-freebsd.

OK to commit?

2015-03-27  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/65429
	* decl.c (add_init_expr_to_sym): Do not dereference a null pointer.

2015-03-27  Steven G. Kargl  <kargl@gcc.gnu.org>

    PR fortran/65429
	* pr65429.f90: New test.

-- 
Steve

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 220943)
+++ gcc/fortran/decl.c	(working copy)
@@ -1406,7 +1406,7 @@ add_init_expr_to_sym (const char *name, 
 		    {
 		      gfc_constructor *c;
 		      c = gfc_constructor_first (init->value.constructor);
-		      clen = c->expr->value.character.length;
+		      clen = c ? c->expr->value.character.length : 0;
 		      sym->ts.u.cl->length
 				= gfc_get_int_expr (gfc_default_integer_kind,
 						    NULL, clen);
Index: gcc/testsuite/gfortran.dg/pr65429.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr65429.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr65429.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do run }
+! PR fortran/65429
+program foo
+character(*), parameter :: s(*)  = [ character(5) :: 'abcde', 'fghij' ]
+if (s(1) /= 'abcde') call abort
+if (s(2) /= 'fghij') call abort
+end program foo
+

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-04-22 23:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28  0:02 [PATCH] fortran/65429 -- don't dereference a null pointer Dominique Dhumieres
2015-03-28  0:33 ` Steve Kargl
2015-03-28 11:42   ` Dominique d'Humières
2015-03-28 14:50     ` Steve Kargl
2015-03-28 15:17       ` Dominique d'Humières
2015-03-29 16:25 ` Steve Kargl
2015-03-31 17:17   ` Jerry DeLisle
2015-04-07 19:59     ` Steve Kargl
2015-04-22 23:18       ` Steve Kargl
  -- strict thread matches above, loose matches on Subject: below --
2015-03-27 22:47 Steve Kargl
2015-03-27 23:50 ` Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).