From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E2A123857C4E; Fri, 7 Aug 2020 20:36:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2A123857C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596832611; bh=agMefnvMVKAgJvFVU6CW7ZOb8tXkhSWmVEa6HHD8ys8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yAfdIc0t7GLSaNPB9kp+pA81sCZetGNqTVAPk8Y2f/lgJMx6y7/vSv0MqppbmorKM u9OmxV2lra5mQh406armznCgMZdQ/lRZz9Lgk/fnmv0f4ru8VujudYLdw7OV1nCDit JamDmVOvCJLW+7V4L0ptRVXcVH7Ma++wjK8rELUk= From: "jussilehtola at fedoraproject dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/96486] get_environment_variable crashes for environment variables that are empty strings Date: Fri, 07 Aug 2020 20:36:51 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jussilehtola at fedoraproject dot org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc 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, 07 Aug 2020 20:36:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96486 Susi Lehtola changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|get_environment_variable |get_environment_variable |fails for zero-length |crashes for environment |values |variables that are empty | |strings --- Comment #22 from Susi Lehtola -= -- to repeat: libgfortran crashes when you try to read an environment variable that is an empty string, in the case you have preallocated an array that is= the proper size i.e. zero characters. I don't get any more backtrace than what I've reported above; I guess gdb doesn't debug libgfortran intrinsics by default. The procedure I used was $ gfortran -g -Wall readvar2.f90=20 $ export HOSTNAME=3D $ gdb ./a.out (gdb) r Starting program: /tmp/a.out=20 Fortran runtime error: Zero-length string passed as value to get_environment_variable. Error termination. Backtrace: #0 0x401267 in zerolen_value at /tmp/readvar2.f90:17 #1 0x4012c4 in main at /tmp/readvar2.f90:22 [Inferior 1 (process 152269) exited with code 02]=