public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming
@ 2014-08-28 19:19 anlauf at gmx dot de
2014-08-31 21:08 ` [Bug libfortran/62296] " anlauf at gmx dot de
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2014-08-28 19:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
Bug ID: 62296
Summary: EXECUTE_COMMAND_LINE not F2008 conforming
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: anlauf at gmx dot de
It appears that EXECUTE_COMMAND_LINE does not fully conform to F2008
in case the execute command fails.
F2008, 13.7.57 states:
CMDSTAT (optional) shall be a default integer scalar. It is an INTENT (OUT)
argument. It is assigned the value −1 if the processor does not support
command line execution, a processor-dependent positive value if an error
condition occurs, or the value −2 if no error condition occurs but WAIT
is present with the value false and the processor does not support
asynchronous execution. Otherwise it is assigned the value 0.
[...]
If a condition occurs that would assign a nonzero value to CMDSTAT but the
CMDSTAT variable is not present, error termination is initiated.
However, the following example behaves as follows:
program gfcbug126
integer :: stat, cstat
call execute_command_line ("/bin/true", exitstat=stat, cmdstat=cstat)
print *, stat, cstat
call execute_command_line ("/bin/false", exitstat=stat, cmdstat=cstat)
print *, stat, cstat
call execute_command_line ("/bin/true", exitstat=stat)
print *, stat
call execute_command_line ("/bin/false", exitstat=stat)
print *, stat
end
Output:
0 0
1 0
0
1
I think the correct output should be like:
0 0
1 (some positive number, e.g. 1)
0
(error termination)
e.g. xlf 14.1 produces:
0 0
1 1
0
"gfcbug126.f90", line 9: 1525-610 Error encountered while attempting to execute
the command:
/bin/false
Also, the (online) documentation should be adjusted to match the standard.
>From gcc-bugs-return-459427-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 28 21:36:24 2014
Return-Path: <gcc-bugs-return-459427-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28792 invoked by alias); 28 Aug 2014 21:36:23 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28752 invoked by uid 48); 28 Aug 2014 21:36:16 -0000
From: "steven at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/43849] Add _gfortran_finalize function to close down the library
Date: Thu, 28 Aug 2014 21:36:00 -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: 4.5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: steven at gcc dot gnu.org
X-Bugzilla-Status: NEW
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_status cc
Message-ID: <bug-43849-4-Ib2fVS7zNj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-43849-4@http.gcc.gnu.org/bugzilla/>
References: <bug-43849-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg01924.txt.bz2
Content-length: 699
https://gcc.gnu.org/bugzilla/show_bug.cgi?idC849
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
CC| |steven at gcc dot gnu.org
--- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #4)
> Is this PR still pertinent (2013-12-21)?
Yes, it could be necessary to force the shutdown from other libraries
that may want to output something and will need the buffers to be
flushed for that (e.g. libcaf).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
@ 2014-08-31 21:08 ` anlauf at gmx dot de
2014-09-02 12:03 ` dominiq at lps dot ens.fr
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2014-08-31 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
--- Comment #1 from Harald Anlauf <anlauf at gmx dot de> ---
There was some confusion on my side regarding the semantics of
the CMDSTAT argument on my side. I asked at
https://groups.google.com/forum/?hl=en#!topic/comp.lang.fortran/6ymZIb6flDg
where there was consensus that CMDSTAT should be zero if the command line
could be executed, even if the exit status is non-zero.
However, if the command could *not* be executed, there should be a
non-zero value for CMDSTAT. However, modifying the code to
integer :: stat, cstat
character(len=255) :: cmdmsg
cmdmsg = ""
call execute_command_line ("/bin/true", exitstat=stat, cmdstat=cstat,
cmdmsg=cmdmsg)
print *, stat, cstat, "'", trim (cmdmsg), "'"
call execute_command_line ("/bin/false", exitstat=stat, cmdstat=cstat,
cmdmsg=cmdmsg)
print *, stat, cstat, "'", trim (cmdmsg), "'"
call execute_command_line ("/nosuchfile",exitstat=stat, cmdstat=cstat,
cmdmsg=cmdmsg)
print *, stat, cstat, "'", trim (cmdmsg), "'"
call execute_command_line ("/bin/true", exitstat=stat)
print *, stat
call execute_command_line ("/bin/false", exitstat=stat)
print *, stat
call execute_command_line ("/nosuchfile",exitstat=stat)
print *, stat
end
produces:
0 0 ''
1 0 ''
sh: /nosuchfile: No such file or directory
127 0 ''
0
1
sh: /nosuchfile: No such file or directory
127
Thus the attempt to execute a non-existing command does not lead
to an appropriate error. Looking at execute_command_line.c, the
execution uses system(). The Linux man page system(3) says:
It is possible for the shell command to return 127, so that code is not
a sure indication that the execve(2) call failed.
Unfortunately the man page does not say whether errno is set,
as it is done for execve(2). So it might be necessary to replace
system(3) by something like fork/exec to get the error status.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
2014-08-31 21:08 ` [Bug libfortran/62296] " anlauf at gmx dot de
@ 2014-09-02 12:03 ` dominiq at lps dot ens.fr
2014-09-02 20:03 ` anlauf at gmx dot de
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-09-02 12:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-09-02
Ever confirmed|0 |1
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
On x86_64-apple-darwin13.3, for the test in comment 1 I get
0 0 ''
sh: /bin/false: No such file or directory
127 0 ''
sh: /nosuchfile: No such file or directory
127 0 ''
0
sh: /bin/false: No such file or directory
127
sh: /nosuchfile: No such file or directory
127
From
https://groups.google.com/forum/?hl=en#!topic/comp.lang.fortran/6ymZIb6flDg it
seems that you are expecting too much of the EXECUTE_COMMAND_LINE options.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
2014-08-31 21:08 ` [Bug libfortran/62296] " anlauf at gmx dot de
2014-09-02 12:03 ` dominiq at lps dot ens.fr
@ 2014-09-02 20:03 ` anlauf at gmx dot de
2014-12-04 21:10 ` anlauf at gmx dot de
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2014-09-02 20:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
--- Comment #3 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Dominique d'Humieres from comment #2)
> On x86_64-apple-darwin13.3, for the test in comment 1 I get
>
> 0 0 ''
> sh: /bin/false: No such file or directory
> 127 0 ''
> sh: /nosuchfile: No such file or directory
> 127 0 ''
> 0
> sh: /bin/false: No such file or directory
> 127
> sh: /nosuchfile: No such file or directory
> 127
>
> From
> https://groups.google.com/forum/?hl=en#!topic/comp.lang.fortran/6ymZIb6flDg
> it seems that you are expecting too much of the EXECUTE_COMMAND_LINE options.
Probably. I'm now wondering why EXECUTE_COMMAND_LINE was standardized
in a way that allows for ambiguous implementations without any reliable
advantage over the non-standard "SYSTEM" implementations.
One might be able to do better on any reasonable Unix/Linux system.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
` (2 preceding siblings ...)
2014-09-02 20:03 ` anlauf at gmx dot de
@ 2014-12-04 21:10 ` anlauf at gmx dot de
2014-12-06 14:52 ` dominiq at lps dot ens.fr
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2014-12-04 21:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
--- Comment #4 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Harald Anlauf from comment #3)
> One might be able to do better on any reasonable Unix/Linux system.
Replying to myself: Intel has changed/fixed their implementation of
EXECUTE_COMMAND_LINE in version 15.1, and it appears to work
reasonably now.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
` (3 preceding siblings ...)
2014-12-04 21:10 ` anlauf at gmx dot de
@ 2014-12-06 14:52 ` dominiq at lps dot ens.fr
2015-08-14 7:56 ` fxcoudert at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-06 14:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
(In reply to Harald Anlauf from comment #4)
> (In reply to Harald Anlauf from comment #3)
> > One might be able to do better on any reasonable Unix/Linux system.
>
> Replying to myself: Intel has changed/fixed their implementation of
> EXECUTE_COMMAND_LINE in version 15.1, and it appears to work
> reasonably now.
What does it mean for gfortran?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
` (4 preceding siblings ...)
2014-12-06 14:52 ` dominiq at lps dot ens.fr
@ 2015-08-14 7:56 ` fxcoudert at gcc dot gnu.org
2015-08-23 21:25 ` fxcoudert at gcc dot gnu.org
2015-08-23 21:28 ` fxcoudert at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-14 7:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |ASSIGNED
CC| |fxcoudert at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |fxcoudert at gcc dot gnu.org
--- Comment #7 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Patch proposed: https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00758.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
` (5 preceding siblings ...)
2015-08-14 7:56 ` fxcoudert at gcc dot gnu.org
@ 2015-08-23 21:25 ` fxcoudert at gcc dot gnu.org
2015-08-23 21:28 ` fxcoudert at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-23 21:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
--- Comment #8 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Author: fxcoudert
Date: Sun Aug 23 21:24:49 2015
New Revision: 227105
URL: https://gcc.gnu.org/viewcvs?rev=227105&root=gcc&view=rev
Log:
PR libfortran/62296
* intrinsics/execute_command_line.c (EXEC_INVALIDCOMMAND): New
error code.
(cmdmsg_values): New error message.
(set_cmdstat): Rework runtime error.
(execute_command_line): Handle invalid command line error status.
* gfortran.dg/execute_command_line_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/execute_command_line_2.f90
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/intrinsics/execute_command_line.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libfortran/62296] EXECUTE_COMMAND_LINE not F2008 conforming
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
` (6 preceding siblings ...)
2015-08-23 21:25 ` fxcoudert at gcc dot gnu.org
@ 2015-08-23 21:28 ` fxcoudert at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-23 21:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62296
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |6.0
--- Comment #9 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Fixed on trunk.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-08-23 21:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-28 19:19 [Bug libfortran/62296] New: EXECUTE_COMMAND_LINE not F2008 conforming anlauf at gmx dot de
2014-08-31 21:08 ` [Bug libfortran/62296] " anlauf at gmx dot de
2014-09-02 12:03 ` dominiq at lps dot ens.fr
2014-09-02 20:03 ` anlauf at gmx dot de
2014-12-04 21:10 ` anlauf at gmx dot de
2014-12-06 14:52 ` dominiq at lps dot ens.fr
2015-08-14 7:56 ` fxcoudert at gcc dot gnu.org
2015-08-23 21:25 ` fxcoudert at gcc dot gnu.org
2015-08-23 21:28 ` fxcoudert at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).