From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DDD9F385BF81; Fri, 10 Apr 2020 16:49:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDD9F385BF81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586537372; bh=+ZMDr6M/2J7dEAcRc0rZrQ7v74vTHvdZucimhmvBTC0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XHuMOkp6oXj9H4d45/Fxfjyo+f25EczCcAOrHRf9+Mf8iG8fz5ouvMqh7EKW7ehaJ nd8z54cMdUOgnZUbVICEdH5NLDcPapRcU89rvJjxas1ZEGT5Okla0BdYXOUBW8jGq4 Q2RVRe+PbNNA19I9CToxpqNYcBmXMrLVPiEKgP2s= From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/93762] Truncation of deferred-length string when passing as optional Date: Fri, 10 Apr 2020 16:49:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 8.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: NEW 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: everconfirmed bug_status cf_reconfirmed_on cc Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2020 16:49:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93762 Thomas Koenig changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2020-04-10 CC| |tkoenig at gcc dot gnu.org --- Comment #1 from Thomas Koenig --- Unfortunately, the test case fails with different ways on current trunk: $ gfortran -g a.f90 $ ./a.out at bot of deepest_call, str is "12345" Program received signal SIGSEGV: Segmentation fault - invalid memory refere= nce. Backtrace for this error: #0 0x7f0a66c3059f in ??? at /usr/src/debug/glibc-2.26-lp151.19.11.1.x86_64/signal/../sysdeps/unix/sysv/= linux/x86_64/sigaction.c:0 #1 0x400c65 in __interface_call_m_MOD_interface_call at /tmp/a.f90:20 #2 0x400d99 in MAIN__ at /tmp/a.f90:32 #3 0x400f0b in main at /tmp/a.f90:25 Speicherzugriffsfehler (Speicherabzug geschrieben) (gdb) r a.f90=20 Starting program: /tmp/a.out a.f90 at bot of deepest_call, str is "12345" Program received signal SIGSEGV, Segmentation fault. _gfortran_string_len_trim (s=3D0x6068d0 "12345", len=3D) at ../../../gcc/libgfortran/intrinsics/string_intrinsics_inc.c:231 231 if (*((unsigned long*) (s + i + 1)) !=3D blank_longword) (gdb) p s $1 =3D 0x6068d0 "12345" (gdb) p i $2 =3D 564082115390472183 Seems like uninitialzed memory for i. Valgrind confirms this: $ valgrind ./a.out =3D=3D5621=3D=3D Memcheck, a memory error detector =3D=3D5621=3D=3D Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward e= t al. =3D=3D5621=3D=3D Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyri= ght info =3D=3D5621=3D=3D Command: ./a.out =3D=3D5621=3D=3D=20 at bot of deepest_call, str is "12345" =3D=3D5621=3D=3D Conditional jump or move depends on uninitialised value(s) =3D=3D5621=3D=3D at 0x50A29A5: _gfortran_string_len_trim (string_intrinsics_inc.c:188) =3D=3D5621=3D=3D by 0x50A2A87: _gfortran_string_trim (string_intrinsics_= inc.c:168) =3D=3D5621=3D=3D by 0x400C65: __interface_call_m_MOD_interface_call (a.f= 90:20) =3D=3D5621=3D=3D by 0x400D99: MAIN__ (a.f90:32) =3D=3D5621=3D=3D by 0x400F0B: main (a.f90:25) Not sure if this ever worked in a released version.=