Bug 89842 - CFI_allocate fails to allocate object
Summary: CFI_allocate fails to allocate object
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-27 09:36 UTC by Bader@lrz.de
Modified: 2019-03-30 15:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-03-27 00:00:00


Attachments
UNIX archive with test case (834 bytes, application/x-tar)
2019-03-27 09:36 UTC, Bader@lrz.de
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bader@lrz.de 2019-03-27 09:36:26 UTC
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)
Comment 1 Dominique d'Humieres 2019-03-27 14:10:12 UTC
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
Comment 2 Paul Thomas 2019-03-30 15:39:32 UTC
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
Comment 3 Paul Thomas 2019-03-30 15:44:05 UTC
Fixed on trunk.

Thanks for the report.

Paul