This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/51972] [OOP] ALLOCATE misses memset/calloc, causing segfault
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 28 Jan 2012 15:58:37 +0000
- Subject: [Bug fortran/51972] [OOP] ALLOCATE misses memset/calloc, causing segfault
- Auto-submitted: auto-generated
- References: <bug-51972-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51972
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-28 15:58:37 UTC ---
The following patch fixes the test case.
However, if one comments the "STOP 'Success'" line, one sees that there is
another bug (double free). The problem is that _copy does not properly do a
deep copy.
Expected: A deep copy of both attractor%state and
attractor%integrand%quadrature.
Currently:
__copy_lorenz_module_Lorenz
{
*dst = *src;
dst->integrand = src->integrand;
__builtin_memcpy (dst->state.data, src->state.data, D.1953 * 4);
Thus, there is no deep copy of "attractor%integrand%quadrature"; thus, both
src->integrand->quadrature->_data and dst->integrand->quadrature->_data point
to the same memory, causing - for the example program - a segfault at the end
of the main program.
--- trans-stmt.c (Revision 183664)
+++ trans-stmt.c (Arbeitskopie)
@@ -4953 +4953,2 @@ gfc_trans_allocate (gfc_code * code)
- if (expr->ts.type == BT_DERIVED &&
expr->ts.u.derived->attr.alloc_comp)
+ if (al->expr->ts.type == BT_DERIVED
+ && expr->ts.u.derived->attr.alloc_comp)