* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
@ 2010-07-31 13:56 Dominique Dhumieres
2010-07-31 14:19 ` Janus Weil
0 siblings, 1 reply; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 13:56 UTC (permalink / raw)
To: fortran; +Cc: gcc-patches, janus
Janus,
Compiling gcc/fortran/module.c with the patch fails with:
...
/opt/gcc/build_w/./prev-gcc/xgcc -B/opt/gcc/build_w/./prev-gcc/ -B/opt/gcc/gcc4.6w/x86_64-apple-darwin10.4.0/bin/ -B/opt/gcc/gcc4.6w/x86_64-apple-darwin10.4.0/bin/ -B/opt/gcc/gcc4.6w/x86_64-apple-darwin10.4.0/lib/ -isystem /opt/gcc/gcc4.6w/x86_64-apple-darwin10.4.0/include -isystem /opt/gcc/gcc4.6w/x86_64-apple-darwin10.4.0/sys-include -c -DIN_GCC_FRONTEND -g -O2 -gtoggle -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common -DHAVE_CONFIG_H -I. -Ifortran -I../../work/gcc -I../../work/gcc/fortran -I../../work/gcc/../include -I../../work/gcc/../libcpp/include -I/opt/sw64/include -I../../work/gcc/../libdecnumber -I../../work/gcc/../libdecnumber/dpd -I../libdecnumber -I/opt/sw64/include -DCLOOG_PPL_BACKEND -I/opt/sw64/include ../../work/gcc/fortran/module.c -o fortran/module.o
../../work/gcc/fortran/module.c: In function 'read_module':
../../work/gcc/fortran/module.c:4374:4: error: implicit declaration of function 'strndup' [-Werror=implicit-function-declaration]
../../work/gcc/fortran/module.c:4374:30: error: incompatible implicit declaration of built-in function 'strndup' [-Werror]
cc1: all warnings being treated as errors
make[3]: *** [fortran/module.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all-stage2-gcc] Error 2
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2
TIA
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 13:56 [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP Dominique Dhumieres
@ 2010-07-31 14:19 ` Janus Weil
2010-07-31 14:21 ` Dominique Dhumieres
2010-07-31 14:28 ` Dominique Dhumieres
0 siblings, 2 replies; 12+ messages in thread
From: Janus Weil @ 2010-07-31 14:19 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
Hi Dominique,
> ../../work/gcc/fortran/module.c: In function 'read_module':
> ../../work/gcc/fortran/module.c:4374:4: error: implicit declaration of function 'strndup' [-Werror=implicit-function-declaration]
> ../../work/gcc/fortran/module.c:4374:30: error: incompatible implicit declaration of built-in function 'strndup' [-Werror]
good point. Guess that should be an 'xstrndup' ...
Cheers,
Janus
[-- Attachment #2: pr44912.diff --]
[-- Type: application/octet-stream, Size: 1605 bytes --]
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 162774)
+++ gcc/fortran/class.c (working copy)
@@ -178,6 +178,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_a
gcc_assert (vtab);
c->ts.u.derived = vtab->ts.u.derived;
}
+ c->attr.access = ACCESS_PRIVATE;
c->attr.pointer = 1;
}
@@ -343,6 +344,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
vtab->attr.target = 1;
vtab->attr.save = SAVE_EXPLICIT;
vtab->attr.vtab = 1;
+ vtab->attr.access = ACCESS_PUBLIC;
vtab->refs++;
gfc_set_sym_referenced (vtab);
sprintf (name, "vtype$%s", derived->name);
@@ -357,6 +359,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
if (gfc_add_flavor (&vtype->attr, FL_DERIVED,
NULL, &gfc_current_locus) == FAILURE)
goto cleanup;
+ vtype->attr.access = ACCESS_PUBLIC;
vtype->refs++;
gfc_set_sym_referenced (vtype);
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (revision 162774)
+++ gcc/fortran/module.c (working copy)
@@ -4370,6 +4370,11 @@ read_module (void)
if (p == NULL && strcmp (name, module_name) == 0)
p = name;
+ /* Exception: Always import vtabs & vtypes. */
+ if (p == NULL && (strcmp (xstrndup (name,5), "vtab$") == 0
+ || strcmp (xstrndup (name,6), "vtype$") == 0))
+ p = name;
+
/* Skip symtree nodes not in an ONLY clause, unless there
is an existing symtree loaded from another USE statement. */
if (p == NULL)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:19 ` Janus Weil
@ 2010-07-31 14:21 ` Dominique Dhumieres
2010-07-31 14:28 ` Janus Weil
2010-07-31 14:28 ` Dominique Dhumieres
1 sibling, 1 reply; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 14:21 UTC (permalink / raw)
To: janus, dominiq; +Cc: gcc-patches, fortran
Janus,
> Guess that should be an 'xstrndup'
That was what I guessed too;-)
Your patch seems to fix also some of the tests in pr42051, pr43896, and pr44064.
It also causes some ICEs on invalid(?) codes such as
pr43207.f90:29.19:
this_parent => this%parent ! <<<<<<<<<<<<
1
Error: Pointer assignment target is neither TARGET nor POINTER at (1)
pr43207.f90:13:0: internal compiler error: in next_statement, at fortran/parse.c:894
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Thanks for the patch,
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:21 ` Dominique Dhumieres
@ 2010-07-31 14:28 ` Janus Weil
2010-07-31 14:46 ` Dominique Dhumieres
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Janus Weil @ 2010-07-31 14:28 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: gcc-patches, fortran
>> Guess that should be an 'xstrndup'
>
> That was what I guessed too;-)
>
> Your patch seems to fix also some of the tests in pr42051, pr43896, and pr44064.
Huh. Hadn't most of these been fixed already?
> It also causes some ICEs on invalid(?) codes such as
>
> pr43207.f90:29.19:
>
> this_parent => this%parent ! <<<<<<<<<<<<
> 1
> Error: Pointer assignment target is neither TARGET nor POINTER at (1)
> pr43207.f90:13:0: internal compiler error: in next_statement, at fortran/parse.c:894
I'll have a look at that ...
Thanks for testing,
Janus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:28 ` Janus Weil
@ 2010-07-31 14:46 ` Dominique Dhumieres
2010-07-31 16:55 ` Dominique Dhumieres
2010-07-31 22:41 ` Dominique Dhumieres
2 siblings, 0 replies; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 14:46 UTC (permalink / raw)
To: janus, dominiq; +Cc: gcc-patches, fortran
> Huh. Hadn't most of these been fixed already?
I think these tests failed to link with something such as
[macbook] f90/bug% gfcp pr42051.f90
Undefined symbols:
"_vtab$grid.1632", referenced from:
___field_module_MOD_output in ccJTnnoI.o
___field_module_MOD_output in ccJTnnoI.o
___field_module_MOD_output in ccJTnnoI.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
The ICE in fortran/parse.c:894 may have been introduced by
Mikeal Morin's commit (r162776?).
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:28 ` Janus Weil
2010-07-31 14:46 ` Dominique Dhumieres
@ 2010-07-31 16:55 ` Dominique Dhumieres
2010-08-01 9:44 ` Janus Weil
2010-07-31 22:41 ` Dominique Dhumieres
2 siblings, 1 reply; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 16:55 UTC (permalink / raw)
To: janus, dominiq; +Cc: gcc-patches, fortran
Janus,
The ICEs I saw are likely due tp revision 162776 (see pr45151).
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 16:55 ` Dominique Dhumieres
@ 2010-08-01 9:44 ` Janus Weil
2010-08-01 14:13 ` Jerry DeLisle
0 siblings, 1 reply; 12+ messages in thread
From: Janus Weil @ 2010-08-01 9:44 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: gcc-patches, fortran
> The ICEs I saw are likely due tp revision 162776 (see pr45151).
At r162774 (plus my patch) I don't see any of these ICEs. So they are
definitely not connected to my patch (which btw still needs approval
...)
Cheers,
Janus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-08-01 9:44 ` Janus Weil
@ 2010-08-01 14:13 ` Jerry DeLisle
2010-08-01 19:25 ` Janus Weil
0 siblings, 1 reply; 12+ messages in thread
From: Jerry DeLisle @ 2010-08-01 14:13 UTC (permalink / raw)
To: Janus Weil; +Cc: Dominique Dhumieres, gcc-patches, fortran
On 08/01/2010 02:44 AM, Janus Weil wrote:
>> The ICEs I saw are likely due tp revision 162776 (see pr45151).
>
> At r162774 (plus my patch) I don't see any of these ICEs. So they are
> definitely not connected to my patch (which btw still needs approval
> ...)
OK
Jerry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:28 ` Janus Weil
2010-07-31 14:46 ` Dominique Dhumieres
2010-07-31 16:55 ` Dominique Dhumieres
@ 2010-07-31 22:41 ` Dominique Dhumieres
2 siblings, 0 replies; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 22:41 UTC (permalink / raw)
To: janus, dominiq; +Cc: gcc-patches, fortran
After having reverted
gcc_assert (changed_syms == NULL);
in revision 162776, the patch works without regression as
described in my previous mails.
Thanks,
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
2010-07-31 14:19 ` Janus Weil
2010-07-31 14:21 ` Dominique Dhumieres
@ 2010-07-31 14:28 ` Dominique Dhumieres
1 sibling, 0 replies; 12+ messages in thread
From: Dominique Dhumieres @ 2010-07-31 14:28 UTC (permalink / raw)
To: janus, dominiq; +Cc: gcc-patches, fortran
I also see:
FAIL: gfortran.dg/abstract_type_6.f03 -O (internal compiler error)
and it is the same ICE I just reported:
...
Error: 'proc_b' at (1) should be a SUBROUTINE
f951: internal compiler error: in next_statement, at fortran/parse.c:894
...
Dominique
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP
@ 2010-07-31 11:45 Janus Weil
0 siblings, 0 replies; 12+ messages in thread
From: Janus Weil @ 2010-07-31 11:45 UTC (permalink / raw)
To: gfortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 958 bytes --]
Hi all,
this patch fixes a problem with type-bound procedure calls segfaulting
at runtime. It is fixed by making the vtabs & vtypes public inside a
module, plus making sure that they are imported upon module loading,
even with "use, only" clauses.
[The patch also contains one hunk which makes the '$vptr' component of
the class container private. This had been done for the '$data'
component already, but has been forgotten for '$vptr'. This is not
actually connected to this PR.]
The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?
Cheers,
Janus
2010-07-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/44912
* class.c (gfc_build_class_symbol): Make '$vptr' component private.
(gfc_find_derived_vtab): Make vtabs and vtypes public.
* module.c (read_module): When reading module files, always import
vtab and vtype symbols.
2010-07-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/44912
* gfortran.dg/typebound_call_17.f03: New.
[-- Attachment #2: pr44912.diff --]
[-- Type: application/octet-stream, Size: 1603 bytes --]
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 162774)
+++ gcc/fortran/class.c (working copy)
@@ -178,6 +178,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_a
gcc_assert (vtab);
c->ts.u.derived = vtab->ts.u.derived;
}
+ c->attr.access = ACCESS_PRIVATE;
c->attr.pointer = 1;
}
@@ -343,6 +344,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
vtab->attr.target = 1;
vtab->attr.save = SAVE_EXPLICIT;
vtab->attr.vtab = 1;
+ vtab->attr.access = ACCESS_PUBLIC;
vtab->refs++;
gfc_set_sym_referenced (vtab);
sprintf (name, "vtype$%s", derived->name);
@@ -357,6 +359,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
if (gfc_add_flavor (&vtype->attr, FL_DERIVED,
NULL, &gfc_current_locus) == FAILURE)
goto cleanup;
+ vtype->attr.access = ACCESS_PUBLIC;
vtype->refs++;
gfc_set_sym_referenced (vtype);
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (revision 162774)
+++ gcc/fortran/module.c (working copy)
@@ -4370,6 +4370,11 @@ read_module (void)
if (p == NULL && strcmp (name, module_name) == 0)
p = name;
+ /* Exception: Always import vtabs & vtypes. */
+ if (p == NULL && (strcmp (strndup (name,5), "vtab$") == 0
+ || strcmp (strndup (name,6), "vtype$") == 0))
+ p = name;
+
/* Skip symtree nodes not in an ONLY clause, unless there
is an existing symtree loaded from another USE statement. */
if (p == NULL)
[-- Attachment #3: typebound_call_17.f03 --]
[-- Type: application/octet-stream, Size: 1196 bytes --]
! { dg-do run }
!
! PR 44912: [OOP] Segmentation fault on TBP
!
! Contributed by Satish.BD <bdsatish@gmail.com>
module polynomial
implicit none
private
type, public :: polynom
complex, allocatable, dimension(:) :: a
integer :: n
contains
procedure :: init_from_coeff
procedure :: get_degree
procedure :: add_poly
end type polynom
contains
subroutine init_from_coeff(self, coeff)
class(polynom), intent(inout) :: self
complex, dimension(:), intent(in) :: coeff
self%n = size(coeff) - 1
allocate(self%a(self%n + 1))
self%a = coeff
print *,"ifc:",self%a
end subroutine init_from_coeff
function get_degree(self) result(n)
class(polynom), intent(in) :: self
integer :: n
print *,"gd"
n = self%n
end function get_degree
subroutine add_poly(self)
class(polynom), intent(in) :: self
integer :: s
print *,"ap"
s = self%get_degree() !!!! fails here
end subroutine
end module polynomial
program test_poly
use polynomial, only: polynom
type(polynom) :: p1
call p1%init_from_coeff([(1,0),(2,0),(3,0)])
call p1%add_poly()
end program test_poly
! { dg-final { cleanup-modules "polynomial" } }
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-08-01 19:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-31 13:56 [Patch, Fortran, OOP] PR 44912: Segmentation fault on TBP Dominique Dhumieres
2010-07-31 14:19 ` Janus Weil
2010-07-31 14:21 ` Dominique Dhumieres
2010-07-31 14:28 ` Janus Weil
2010-07-31 14:46 ` Dominique Dhumieres
2010-07-31 16:55 ` Dominique Dhumieres
2010-08-01 9:44 ` Janus Weil
2010-08-01 14:13 ` Jerry DeLisle
2010-08-01 19:25 ` Janus Weil
2010-07-31 22:41 ` Dominique Dhumieres
2010-07-31 14:28 ` Dominique Dhumieres
-- strict thread matches above, loose matches on Subject: below --
2010-07-31 11:45 Janus Weil
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).