From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ACC09382BEB5; Wed, 14 Dec 2022 18:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACC09382BEB5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671043054; bh=aUI3iqeScJve9EMyS5Zlxi1KZGyVd6C/OwMyWgq9eTc=; h=From:To:Subject:Date:From; b=EMIJlCO54PajI0rDhgcaJkxoIUMIFgKZnYkIyyI88+wjMlFDvVx8913Xnx5VFf7YL OKsJwgx8eK4DSuxtQouRdn7eyy++aoHiqrOEa11OljKvKacqPckQzPbHnVcpM+L/iJ 3Mpo5scsVdyq6fc53z5fuwodV/gtCgYP8Gx0z3ak= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/108109] New: [ICE] gfortran compilation fails calling 'free()' with 'malloc(): mismatching next->prev_size (unsorted)' Date: Wed, 14 Dec 2022 18:37:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108109 Bug ID: 108109 Summary: [ICE] gfortran compilation fails calling 'free()' with 'malloc(): mismatching next->prev_size (unsorted)' Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Created attachment 54092 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54092&action=3Dedit Testcase - compile with 'gfortran test.f90' Fails with GCC 13, 12 and 11. Found when looking at https://github.com/olcf/openmp-gpu-library , namely t= he MatrixMultiply_OpenMP_HIP_ROCm/MM_GPU_Library_Module.f90 example. Lacking some modules, it fails to compile (expected) but during error recov= ery, it seems as if the memory is somehow corrupting, crashing GCC as follows without a backtrace: corrupted size vs. prev_size corrupted size vs. prev_size gfortran: internal compiler error: Aborted signal terminated program f951 The slightly reduced attached testcase fails likewise. * * * There is no backtrace, but running it in gdb shows: #1 0x00007ffff77b0859 in __GI_abort () at abort.c:79 #2 0x00007ffff781b26e in __libc_message (action=3Daction@entry=3Ddo_abort, fmt=3Dfmt@entry=3D0x7ffff7945298 "%s\n") at ../sysdeps/posix/libc_fatal.c:1= 55 #3 0x00007ffff78232fc in malloc_printerr (str=3Dstr@entry=3D0x7ffff7947aa0 "malloc(): mismatching next->prev_size (unsorted)") at malloc.c:5347 #4 0x00007ffff782635c in _int_malloc (av=3Dav@entry=3D0x7ffff797ab80 , bytes=3Dbytes@entry=3D2792) at malloc.c:3741 #5 0x00007ffff7829b95 in __libc_calloc (n=3D, elem_size=3D) at malloc.c:3428 #6 0x0000000002006b35 in xcalloc (nelem=3D1, elsize=3D2792) at ../../repos/gcc-trunk-commit/libiberty/xmalloc.c:164 #7 0x000000000097efaf in gfc_get_namespace (parent=3Dparent@entry=3D0x2d06= 9d0, parent_types=3Dparent_types@entry=3D0) at ../../repos/gcc-trunk-commit/gcc/fortran/symbol.cc:2869 #8 0x0000000000981df6 in gfc_copy_formal_args_intr (dest=3Ddest@entry=3D0x= 2d1eb60, src=3Dsrc@entry=3D0x7ffff6f9ec90, actual=3Dactual@entry=3D0x0,=20 copy_type=3Dcopy_type@entry=3Dfalse) at ../../repos/gcc-trunk-commit/gcc/fortran/symbol.cc:4683 #9 0x000000000094c128 in gfc_resolve_intrinsic (sym=3Dsym@entry=3D0x2d1eb6= 0, loc=3Dloc@entry=3D0x2d1eb70) at ../../repos/gcc-trunk-commit/gcc/fortran/resolve.cc:1887 #10 0x000000000094d94c in resolve_symbol (sym=3D) at ../../repos/gcc-trunk-commit/gcc/fortran/resolve.cc:15788 #11 0x0000000000978853 in do_traverse_symtree (st=3D, st_fun= c=3D0x0, sym_func=3D0x94cd70 ) at ../../repos/gcc-trunk-commit/gcc/fortran/symbol.cc:4186 #12 0x0000000000958b1f in resolve_types (ns=3D0x2d069d0) at ../../repos/gcc-trunk-commit/gcc/fortran/resolve.cc:17551 #13 0x000000000095f6ed in gfc_resolve (ns=3D0x2d069d0) at ../../repos/gcc-trunk-commit/gcc/fortran/resolve.cc:17666 #14 0x000000000094cd5e in gfc_resolve (ns=3D) at ../../repos/gcc-trunk-commit/gcc/fortran/resolve.cc:17653 * * * The call looks harmless: #6 0x0000000002006b35 in xcalloc (nelem=3D1, elsize=3D2792) at ../../repos/gcc-trunk-commit/libiberty/xmalloc.c:164 164 newmem =3D calloc (nelem, elsize); (gdb)=20 #7 0x000000000097efaf in gfc_get_namespace (parent=3Dparent@entry=3D0x2d06= 9d0, parent_types=3Dparent_types@entry=3D0) at ../../repos/gcc-trunk-commit/gcc/fortran/symbol.cc:2869 2869 ns =3D XCNEW (gfc_namespace); which implies the actual issue is likely much before!=