Created attachment 46030 [details] UNIX archive with test case Please compile the test code from the attached archive as follows: gcc -g -c allocate_01_pos.c gfortran -g -ftraceback allocate_01_pos.f90 allocate_01_pos.o The resulting executable fails with symptoms of memory corruption that vary between runs. Not uncommonly, the following error message is printed: a.out: malloc.c:2399: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed. Program received signal SIGABRT: Process abort signal. Backtrace for this error: #0 0x7f705b2bffdf in ??? #1 0x7f705b2bff67 in ??? #2 0x7f705b2c1339 in ??? #3 0x7f705b30419c in ??? #4 0x7f705b306076 in ??? #5 0x7f705b306a80 in ??? #6 0x7f705b308d93 in ??? #7 0x7f705bfb07dd in CFI_allocate at ../../../libgfortran/runtime/ISO_Fortran_binding.c:257 #8 0x400ed6 in globalp at /home/hpc/pr28fa/a2832ba/fortran_tests/f18/interop/functions/allocate_01_pos.c:14 #9 0x400a39 in alloc_01 at /home/hpc/pr28fa/a2832ba/fortran_tests/f18/interop/functions/allocate_01_pos.f90:21 #10 0x400e8e in main at /home/hpc/pr28fa/a2832ba/fortran_tests/f18/interop/functions/allocate_01_pos.f90:14 Aborted (core dumped)
On darwin I get a.out(30846,0x119e565c0) malloc: can't allocate region *** mach_vm_map(size=562940412489728) failed (error code=3) a.out(30846,0x119e565c0) malloc: *** set a breakpoint in malloc_error_break to debug CFI_allocate: Failure in memory allocation. FAIL C: status is 11
Author: pault Date: Sat Mar 30 15:39:00 2019 New Revision: 270037 URL: https://gcc.gnu.org/viewcvs?rev=270037&root=gcc&view=rev Log: 2019-03-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/89841 * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Use the formal argument attributes rather than those of the actual argument. PR fortran/89842 * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Call 'set_dtype_for_unallocated' for any type of arrayspec. 2019-03-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/89841 * gfortran.dg/ISO_Fortran_binding_1.f90: Change the interfaces for c_deallocate, c_allocate and c_assumed_size so that the attributes of the array arguments are correct and are typed. * gfortran.dg/ISO_Fortran_binding_7.f90: New test. * gfortran.dg/ISO_Fortran_binding_7.c: Additional source. PR fortran/89842 * gfortran.dg/ISO_Fortran_binding_8.f90: New test. * gfortran.dg/ISO_Fortran_binding_8.c: Additional source. Added: trunk/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.c trunk/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_7.f90 trunk/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.c trunk/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_8.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_1.f90
Fixed on trunk. Thanks for the report. Paul