Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

execute_command_line crashes on nonexisting command

$
0
0

The intrinsic 'execute_command_line' instruction (F2008) crashes on Intel Fortran for Linux 17.0.4 with segmentation fault if the command cannot be found. This is a strange behaviour. I am using the instruction to test if certain executable module can be  run based on the exitstat and cmdstat parameters, but it does not work this way with ifort.

Here is the test code:

program zzz

integer :: int_1 = 0, int_2 = 0
character(len=:), allocatable :: CMD
character(len=255) :: msg_out = "unknown"
CMD="zzz_idontexist"

call execute_command_line( CMD, wait=.TRUE., exitstat=int_1,   &
                           cmdstat=int_2 ,cmdmsg=msg_out )

print *, "Report: ", CMD, int_1, int_2, trim(msg_out)

end program zzz

Here is the output comparing it with GNU gfortran:

$ gfortran test_exec_cmd.f90
$ ./a.out
sh: 1: zzz_idontexist: not found
 Report: zzz_idontexist         127           0 unknown


$ ifort test_exec_cmd.f90
$ ./a.out
sh: 1: zzz_idontexist: not found
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source
a.out              0000000000403144  Unknown               Unknown  Unknown
libpthread-2.19.s  00007F19EECFF330  Unknown               Unknown  Unknown
libc-2.19.so       00007F19EE9B292D  memset                Unknown  Unknown
a.out              0000000000402E92  Unknown               Unknown  Unknown
a.out              0000000000402B19  Unknown               Unknown  Unknown
a.out              000000000040299E  Unknown               Unknown  Unknown
libc-2.19.so       00007F19EE947F45  __libc_start_main     Unknown  Unknown
a.out              00000000004028A9  Unknown               Unknown  Unknown

$ ifort -v
ifort version 17.0.4

Strangely, the same code works on the Windows platform:

O:\WORK>ifort -o zzz.exe test_exec_cmd.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:zzz.exe
-subsystem:console
test_exec_cmd.obj

O:\WORK>zzz.exe'zzz_idontexist' is not recognized as an internal or external command,
operable program or batch file.
 Report: zzz_idontexist           1           0 unknown

O:\WORK>gfortran -o zzz.exe test_exec_cmd.f90

O:\WORK>zzz.exe'zzz_idontexist' is not recognized as an internal or external command,
operable program or batch file.
 Report: zzz_idontexist           1           0 unknown

 


Viewing all articles
Browse latest Browse all 2746

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>