From patchwork Sat Jan 12 22:35:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 1024014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493955-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MQwtZaru"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43cZM95Gyqz9sCh for ; Sun, 13 Jan 2019 09:35:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=wTBR+U9j0Yd21cu921vGDxYuSXqQ6to7kAcUolF31vBf8Rj0Am LKZviESAR5Wxz2nV6AGE2fOvvehif98sSyzI+BPqtyOQG7nEQPA+Wb5VQwyrU0AY xayLQ+IN3wB9PScTIw4Zq96lmvQ0KfVMAqx+c34iCScXJKSWhHd2bpF18= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=3kb26wlG3i80oXGFY67xBaeI/Qk=; b=MQwtZaruS6C5Tx96qUbh nIHQL6Oc0POH2lqwAfpuTDoD7HUPcULKvT6D17kK/ENxbti934mdaw8H6hs6yqXG M8TpB4ucO2v6dMMbmFxZuf0pOIm5ZMVlatl7DTULBAcB3i5LflQbn2fT0sbhHBf0 YqvUxXK1eHQNb+ozINq80kM= Received: (qmail 12555 invoked by alias); 12 Jan 2019 22:35:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12534 invoked by uid 89); 12 Jan 2019 22:35:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:2019011, H*r:InterMail, structures, H*r:charter.net X-HELO: mtaout006-public.msg.strl.va.charter.net Received: from mtaout006-public.msg.strl.va.charter.net (HELO mtaout006-public.msg.strl.va.charter.net) (68.114.190.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Jan 2019 22:35:39 +0000 Received: from impout004 ([68.114.189.19]) by mtaout006.msg.strl.va.charter.net (InterMail vM.9.00.023.01 201-2473-194) with ESMTP id <20190112223537.MOXL7358.mtaout006.msg.strl.va.charter.net@impout004>; Sat, 12 Jan 2019 16:35:37 -0600 Received: from [192.168.1.6] ([66.191.41.128]) by impout004 with charter.net id Pabc1z00A2lujD601abdqZ; Sat, 12 Jan 2019 16:35:37 -0600 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [patch,libgfortran] PR88776 Namelist read from stdin: loss of data Message-ID: <7d651d9d-08c9-4356-9cfa-1673449a7af3@charter.net> Date: Sat, 12 Jan 2019 14:35:36 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Hi all, As stated in the PR, the problem turns out to be an ungraceful return after an error. Most namelist errors go through nml_err_ret, The one I am removing did not and in the unique case of UNIT=5 after the error it falls through and hits some code which modifies pointers to the namelist data structures. This patch fixes it. Regression tested on x86-64 and manually tested with a redirection to stdin. (cat somefile | ./a.out ) I plan to commit today as simple along with a new testcase. Regards. Jerry 2019-01-12 Jerry DeLisle PR libfortran/88776 * io/list_read.c (namelist_read): Use nml_err_ret path on read error, not based on stdin_unit. diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 4a7ccb3ddd5..d9af255a034 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -3614,11 +3614,7 @@ find_nml_name: while (!dtp->u.p.input_complete) { if (!nml_get_obj_data (dtp, &prev_nl, nml_err_msg, sizeof nml_err_msg)) - { - if (dtp->u.p.current_unit->unit_number != options.stdin_unit) - goto nml_err_ret; - generate_error (&dtp->common, LIBERROR_READ_VALUE, nml_err_msg); - } + goto nml_err_ret; /* Reset the previous namelist pointer if we know we are not going to be doing multiple reads within a single namelist object. */