[Fortran, Patch, pr65795, v1] Segfault (invalid write) for ALLOCATE statement involving COARRAYS

Andre Vehreschild vehre@gmx.de
Sun Apr 3 13:36:00 GMT 2016


Hi all,

attached patch fixes a segfault when allocating a coarray of a type
that has allocatable components. Before the patch the compiler tried
to ref the component to nullify from the coarray's base address and not
from its .data component. The proposed patch fixes this by preventing
the nullify of the components in the array_allocate() for coarrays,
because the components are nullified again afterwards by copying a
fully nullified copy of the type to the coarray's data component.

There albeit is an alternative to this patch:

trans-array.c: 5556+

-       tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, se->expr,
+       tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, coarray ?
+  						pointer : se->expr, 
				      ref->u.ar.as->rank);

The above adds a second nullify to the generated code before the one
done the object copy mentioned above. 

Because I am unsure which patch is best, I propose both. I do favor of
course the one without the duplicate nullify as attached.

Bootstrapped and regtested ok on x86_64-linux-gnu/F23. Ok for trunk?

The patch also applies (with a small delta) to gcc-5 w/o any
regressions. Ok for gcc-5-branch?

Regards,
	Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr65795_1.clog
Type: application/octet-stream
Size: 463 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20160403/e1dbe1d4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr65795_1.patch
Type: text/x-patch
Size: 1400 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20160403/e1dbe1d4/attachment.bin>


More information about the Fortran mailing list