Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-12 Thread Jerry D via Fortran

On 8/12/23 6:41 AM, Jorge D'Elia wrote:

Hi Paul,

- Mensaje original -

De: "Paul Richard Thomas" 
Para: "Jerry" 
CC: "Jorge D'Elia" , "Gfortran List" , 
"Jorge D'Elia"

Enviado: Sábado, 12 de Agosto 2023 3:56:44
Asunto: Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) 
gives a signal SIGILL

Hi Jorge,


There were some recent patches in this area IIRC.

Jerry


The tree dump is identical to mine, obtained with GNU Fortran (GCC)
14.0.0 20230809 (experimental), so I doubt that any recent patches are
responsible.


It seems so. Furthermore, I have the feeling that the problem is outside
GFortran, between the use of -mtune=native versus -march=native. For example,

$ gfortran --version
GNU Fortran (GCC) 14.0.0 20230808 (experimental)

$ ls -all
total 4
drwxr-xr-x. 1 jdelia jdelia   16 Aug 12 10:06 .
drwxr-xr-x. 1 jdelia jdelia 2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia  223 Aug 11 08:28 test.f90

$ gfortran -mtune=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -g 
-fdump-tree-original -o test-mtune.exe test.f90
$ ls -all
total 36
drwxr-xr-x. 1 jdelia jdelia   110 Aug 12 10:17 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune-test.f90.005t.original

$ mv test-mtune-test.f90.005t.original test-mtune.f90.005t.original

$ ls -all
total 36
drwxr-xr-x. 1 jdelia jdelia   100 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ gfortran -march=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -g 
-fdump-tree-original -o test-march.exe test.f90
$ ls -all
total 68
drwxr-xr-x. 1 jdelia jdelia   194 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 28064 Aug 12 10:19 test-march.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:19 test-march-test.f90.005t.original
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ mv test-march-test.f90.005t.original test-march.f90.005t.original

$ ls -all
total 68
drwxr-xr-x. 1 jdelia jdelia   184 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 28064 Aug 12 10:19 test-march.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:19 test-march.f90.005t.original
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ diff test-mtune.f90.005t.original test-march.f90.005t.original
# (nothing is shown, thus both tree dumps ares identical).

$ test-mtune.exe
   cc :

$ test-march.exe

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x15268845fb1f in ???
#1  0x4011c2 in test
at /home/jdelia/TEST/test.f90:6
#2  0x4012ae in main
at /home/jdelia/TEST/test.f90:8
Illegal instruction (core dumped)


Being unable to reproduce the error, there is not much that I can do.
Sorry


Non problem. To avoid this error, for now we exclude the use
of -march=native in our makefiles, and just use -mtune=native.


Paul


Thanks for your time.

Regards.
Jorge.
--


I have not been able to reproduce it here.  I tried on:

gcc version 14.0.0 20230804 (experimental) (GCC)

and

gcc version 14.0.0 20230812 (experimental) (GCC)

I wonder if you caught a version in between changes happening?

$ lscpu
Architecture:x86_64
  CPU op-mode(s):32-bit, 64-bit
  Address sizes: 48 bits physical, 48 bits virtual
  Byte Order:Little Endian

I started to draft a PR this morning, not sure.

I know it is a pain to do, can you build a later version of gfortran and 
see if your results are different?


Also, I have seen times where the libgfortran files were out of sync 
with the build because LD_LIBRARY_PATH was not pointing in the correct 
place.  So check these things.


Regards,

Jerry


Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-12 Thread Steve Kargl via Fortran
On Sat, Aug 12, 2023 at 10:41:10AM -0300, Jorge D'Elia via Fortran wrote:
> 
> $ test-march.exe 
> 
> Program received signal SIGILL: Illegal instruction.
> 

This, to me, suggests that the backend is emitting a wrong
assembly language code.  I suspect that you'll need to 
compare the generated assembly code between a working 
gfortran and the bad gfortran.  It is also possible to get
a listing of the actually options that -march=native activates.
For example,

% gfcx -o z -O -march=native --verbose a.f90

It is the options that begin with -m that matter.  For my hardware
I see 108 such options.  With patients you can determine if one 
of these triggers the issues.

One can also scan gcc/gcc/ChangeLog for changes to config/i386/i386.md.
For example 

2023-08-07  Jan Beulich  

* config/i386/i386.md (sse4_1_round2): Make
"length_immediate" uniformly 1.
* config/i386/mmx.md (mmx_pblendvb_v8qi): Likewise.
(mmx_pblendvb_): Likewise.

There are at least 10 commits on 2023-08-07 to this file.

Finally, as a non-git user, you can always try git's bisection
feature to identify where things go left.

-- 
Steve


Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-12 Thread Jorge D'Elia via Fortran
Hi Paul,

- Mensaje original -
> De: "Paul Richard Thomas" 
> Para: "Jerry" 
> CC: "Jorge D'Elia" , "Gfortran List" 
> , "Jorge D'Elia"
> 
> Enviado: Sábado, 12 de Agosto 2023 3:56:44
> Asunto: Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) 
> gives a signal SIGILL
>
> Hi Jorge,
> 
>> There were some recent patches in this area IIRC.
>>
>> Jerry
> 
> The tree dump is identical to mine, obtained with GNU Fortran (GCC)
> 14.0.0 20230809 (experimental), so I doubt that any recent patches are
> responsible.

It seems so. Furthermore, I have the feeling that the problem is outside 
GFortran, between the use of -mtune=native versus -march=native. For example,

$ gfortran --version
GNU Fortran (GCC) 14.0.0 20230808 (experimental)

$ ls -all
total 4
drwxr-xr-x. 1 jdelia jdelia   16 Aug 12 10:06 .
drwxr-xr-x. 1 jdelia jdelia 2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia  223 Aug 11 08:28 test.f90

$ gfortran -mtune=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -g 
-fdump-tree-original -o test-mtune.exe test.f90
$ ls -all
total 36
drwxr-xr-x. 1 jdelia jdelia   110 Aug 12 10:17 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune-test.f90.005t.original

$ mv test-mtune-test.f90.005t.original test-mtune.f90.005t.original

$ ls -all
total 36
drwxr-xr-x. 1 jdelia jdelia   100 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ gfortran -march=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -g 
-fdump-tree-original -o test-march.exe test.f90
$ ls -all
total 68
drwxr-xr-x. 1 jdelia jdelia   194 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 28064 Aug 12 10:19 test-march.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:19 test-march-test.f90.005t.original
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ mv test-march-test.f90.005t.original test-march.f90.005t.original

$ ls -all
total 68
drwxr-xr-x. 1 jdelia jdelia   184 Aug 12 10:19 .
drwxr-xr-x. 1 jdelia jdelia  2782 Aug 12 10:05 ..
-rwxr-xr-x. 1 jdelia jdelia   223 Aug 11 08:28 test.f90
-rwxr-xr-x. 1 jdelia jdelia 28064 Aug 12 10:19 test-march.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:19 test-march.f90.005t.original
-rwxr-xr-x. 1 jdelia jdelia 26856 Aug 12 10:17 test-mtune.exe
-rw-r--r--. 1 jdelia jdelia  1405 Aug 12 10:17 test-mtune.f90.005t.original

$ diff test-mtune.f90.005t.original test-march.f90.005t.original 
# (nothing is shown, thus both tree dumps ares identical).

$ test-mtune.exe 
  cc : 

$ test-march.exe 

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x15268845fb1f in ???
#1  0x4011c2 in test
at /home/jdelia/TEST/test.f90:6
#2  0x4012ae in main
at /home/jdelia/TEST/test.f90:8
Illegal instruction (core dumped)

> Being unable to reproduce the error, there is not much that I can do.
> Sorry

Non problem. To avoid this error, for now we exclude the use 
of -march=native in our makefiles, and just use -mtune=native.

> Paul

Thanks for your time.

Regards.
Jorge.
--


Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-12 Thread Paul Richard Thomas via Fortran
Hi Jorge,

> There were some recent patches in this area IIRC.
>
> Jerry

The tree dump is identical to mine, obtained with GNU Fortran (GCC)
14.0.0 20230809 (experimental), so I doubt that any recent patches are
responsible.

Being unable to reproduce the error, there is not much that I can do.

Sorry

Paul


Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-11 Thread Jorge D'Elia via Fortran
Dear Paul / Jerry,

- Mensaje original -
> De: "Paul Richard Thomas" 
> Para: "Jerry D" 
> CC: "Jorge D'Elia" , "Gfortran List" , "Jorge D'Elia"
> 
> Enviado: Viernes, 11 de Agosto 2023 13:55:43
> Asunto: Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) 
> gives a signal SIGILL
>
> I wonder why the development 14.0.0 doesn't exhibit this behaviour?
> 
> Could you please rerun with the compile options -g -fdump-tree-original .
> 
> The later should generate a file *.original with the content:
> 
> void test ()
> {
>  character(kind=1) cc[1:32];
> 
>  __builtin_memmove ((void *) , (void *) &"
>   "[1]{lb: 1 sz: 1}, 32);
>  {
>struct __st_parameter_dt dt_parm.0;
> 
>dt_parm.0.common.filename = &"test_repeat.f90"[1]{lb: 1 sz: 1};
>dt_parm.0.common.line = 7;
>dt_parm.0.common.flags = 128;
>dt_parm.0.common.unit = 6;
>_gfortran_st_write (_parm.0);
>{
>  character(kind=1) str.1[38];
>  character(kind=1) str.2[41];
> 
>  _gfortran_concat_string (38, (character(kind=1)[1:] *) ,
> 6, &" cc : "[1]{lb: 1 sz: 1}, 32, );
>  _gfortran_concat_string (41, (character(kind=1)[1:] *) ,
> 38, (character(kind=1)[1:] *) , 3, &"end"[1]{lb: 1 sz: 1});
>  _gfortran_transfer_character_write (_parm.0,
> (character(kind=1)[1:] *) , 41);
>}
>_gfortran_st_write_done (_parm.0);
>  }
> }
> 
> Note that repeat is reduced to the builtin memmove with 32 spaces going to cc.


Ok, then using:

$ gfortran --version
GNU Fortran (GCC) 14.0.0 20230808 (experimental)

$ gfortran -mtune=native -march=native -fcheck=all -std=f2018 -Wall -Werror 
-Wextra -g -fdump-tree-original -o test.exe test.f90

$ cat test.f90.005t.original

__attribute__((fn spec (". ")))
void test ()
{
  static logical(kind=4) is_recursive.0 = 0;
  character(kind=1) cc[1:32];

  try
{
  if (is_recursive.0)
{
  _gfortran_runtime_error_at (&"At line 1 of file test.f90"[1]{lb: 1 
sz: 1}, &"Recursive call to nonrecursive procedure \'test\'"[1]{lb: 1 sz: 1});
}
  is_recursive.0 = 1;
  __builtin_memmove ((void *) , (void *) &"  
  "[1]{lb: 1 sz: 1}, 32);
  {
struct __st_parameter_dt dt_parm.1;

dt_parm.1.common.filename = &"test.f90"[1]{lb: 1 sz: 1};
dt_parm.1.common.line = 7;
dt_parm.1.common.flags = 128;
dt_parm.1.common.unit = 6;
_gfortran_st_write (_parm.1);
{
  character(kind=1) str.2[38];

  _gfortran_concat_string (38, (character(kind=1)[1:] *) , 6, &" 
cc : "[1]{lb: 1 sz: 1}, 32, );
  _gfortran_transfer_character_write (_parm.1, 
(character(kind=1)[1:] *) , 38);
}
_gfortran_st_write_done (_parm.1);
  }
}
  finally
{
  is_recursive.0 = 0;
}
}


__attribute__((externally_visible))
integer(kind=4) main (integer(kind=4) argc, character(kind=1) * * argv)
{
  static integer(kind=4) options.3[7] = {1282, 1947, 0, 1, 1, 1, 31};

  _gfortran_set_args (argc, argv);
  _gfortran_set_options (7, [0]);
  test ();
  return 0;
}

$ test.exe 

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x14aded839b1f in ???
#1  0x4011c2 in test
at /home/jdelia/TESTS/test.f90:6
#2  0x4012ae in main
at /home/jdelia/TESTS/test.f90:8
Illegal instruction (core dumped)


> Regards
> Paul
> 
> On Fri, 11 Aug 2023 at 17:21, Jerry D via Fortran  wrote:
>>
>> On 8/11/23 5:34 AM, Jorge D'Elia via Fortran wrote:
>> > Dear GFortran developers,
>> >
>> > With the beta gfortran 14.x.y versions we are noticing some runtime
>> > errors in a production code.
>> >
>> > One type of runtime errors is related to the concurrent use of the
>> > intrinsic "repeat" when the source code is compiled with the
>> > flag -march=native, please, see below:
>> >
>> > $ cat test.f90
>> > program test
>> >implicit none
>> >integer  , parameter :: iin = kind (1)
>> >integer (iin), parameter :: pp = 32
>> >character (len=pp) :: cc
>> >cc (1:pp) = repeat (" ",pp)
>> >write (*,*)" cc : " // cc
>> > end program test
>> >
>> > $ gfortran --version
>> > GNU Fortran (GCC) 14.0.0 20230808 (experimental)
>> > Copyright (C) 2023 Free Software Foundation, Inc.
>> > This is free software; see the source for copying conditions.  There is NO
>> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>

Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-11 Thread Paul Richard Thomas via Fortran
I wonder why the development 14.0.0 doesn't exhibit this behaviour?

Could you please rerun with the compile options -g -fdump-tree-original .

The later should generate a file *.original with the content:

void test ()
{
  character(kind=1) cc[1:32];

  __builtin_memmove ((void *) , (void *) &"
   "[1]{lb: 1 sz: 1}, 32);
  {
struct __st_parameter_dt dt_parm.0;

dt_parm.0.common.filename = &"test_repeat.f90"[1]{lb: 1 sz: 1};
dt_parm.0.common.line = 7;
dt_parm.0.common.flags = 128;
dt_parm.0.common.unit = 6;
_gfortran_st_write (_parm.0);
{
  character(kind=1) str.1[38];
  character(kind=1) str.2[41];

  _gfortran_concat_string (38, (character(kind=1)[1:] *) ,
6, &" cc : "[1]{lb: 1 sz: 1}, 32, );
  _gfortran_concat_string (41, (character(kind=1)[1:] *) ,
38, (character(kind=1)[1:] *) , 3, &"end"[1]{lb: 1 sz: 1});
  _gfortran_transfer_character_write (_parm.0,
(character(kind=1)[1:] *) , 41);
}
_gfortran_st_write_done (_parm.0);
  }
}

Note that repeat is reduced to the builtin memmove with 32 spaces going to cc.

Regards

Paul

On Fri, 11 Aug 2023 at 17:21, Jerry D via Fortran  wrote:
>
> On 8/11/23 5:34 AM, Jorge D'Elia via Fortran wrote:
> > Dear GFortran developers,
> >
> > With the beta gfortran 14.x.y versions we are noticing some runtime
> > errors in a production code.
> >
> > One type of runtime errors is related to the concurrent use of the
> > intrinsic "repeat" when the source code is compiled with the
> > flag -march=native, please, see below:
> >
> > $ cat test.f90
> > program test
> >implicit none
> >integer  , parameter :: iin = kind (1)
> >integer (iin), parameter :: pp = 32
> >character (len=pp) :: cc
> >cc (1:pp) = repeat (" ",pp)
> >write (*,*)" cc : " // cc
> > end program test
> >
> > $ gfortran --version
> > GNU Fortran (GCC) 14.0.0 20230808 (experimental)
> > Copyright (C) 2023 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> >
> > a) Compiling with the flag -mtune=native only, without -march=native, the 
> > test is ok:
> >
> > $ gfortran -mtune=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og 
> > -o test.exe test.f90
> > $ test.exe
> >cc :
> >
> > b) However, compiling with the flag -march=native:
> >
> > $ gfortran -march=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og 
> > -o test.exe test.f90
> > $ test.exe
> >
> > Program received signal SIGILL: Illegal instruction.
> >
> > Backtrace for this error:
> > #0  0x14fae277fb1f in ???
> > #1  0x4011ad in ???
> > #2  0x401272 in ???
> > #3  0x14fae276a50f in ???
> > #4  0x14fae276a5c8 in ???
> > #5  0x4010c4 in ???
> > #6  0x in ???
> > Illegal instruction (core dumped)
> >
> > On the other hand, compiling with the system version (GNU Fortran (GCC)
> > 12.3.1 20230508 (Red Hat 12.3.1-1)) or replacing the intrinsic repeat
> > with:
> >
> > do kk = 1, pp
> >cc (kk:kk) = " "
> > end do
> >
> > both tests are ok. The error occurs on any of Intel or AMD computers,
> > e.g. in the present case:
> >
> > $ lscpu
> > Architecture:   x86_64
> >CPU op-mode(s):   32-bit, 64-bit
> >Address sizes:46 bits physical, 48 bits virtual
> >Byte Order:   Little Endian
> > CPU(s): 6
> >On-line CPU(s) list:  0-5
> > Vendor ID:  GenuineIntel
> >Model name:   Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz
> >  CPU family: 6
> >  Model:  45
> >  Thread(s) per core: 1
> >  Core(s) per socket: 6
> >  Socket(s):  1
> >  Stepping:   7
> >  BogoMIPS:   6400.22
> > Caches (sum of all):
> >L1d:  192 KiB (6 instances)
> >L1i:  192 KiB (6 instances)
> >L2:   1.5 MiB (6 instances)
> >L3:   12 MiB (1 instance)
> > NUMA:
> >NUMA node(s): 1
> >NUMA node0 CPU(s):0-5
> >
> >
> > By the way, I do not know if the -march=native flag or the intrinsic
> > repeat would be of deprecated use (or not)...
>
> Regardless, we should never segfault.  Thanks for the code example. We
> need to get a bug report opened on this.  I am on travel this morning,
> but if I have time i will do so this afternnon if someone else does not
> beat me to it.
>
> There were some recent patches in this area IIRC.
>
> Jerry
>


Re: beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-11 Thread Jerry D via Fortran

On 8/11/23 5:34 AM, Jorge D'Elia via Fortran wrote:

Dear GFortran developers,

With the beta gfortran 14.x.y versions we are noticing some runtime
errors in a production code.

One type of runtime errors is related to the concurrent use of the
intrinsic "repeat" when the source code is compiled with the
flag -march=native, please, see below:

$ cat test.f90
program test
   implicit none
   integer  , parameter :: iin = kind (1)
   integer (iin), parameter :: pp = 32
   character (len=pp) :: cc
   cc (1:pp) = repeat (" ",pp)
   write (*,*)" cc : " // cc
end program test

$ gfortran --version
GNU Fortran (GCC) 14.0.0 20230808 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

a) Compiling with the flag -mtune=native only, without -march=native, the test 
is ok:

$ gfortran -mtune=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og -o 
test.exe test.f90
$ test.exe
   cc :

b) However, compiling with the flag -march=native:

$ gfortran -march=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og -o 
test.exe test.f90
$ test.exe

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x14fae277fb1f in ???
#1  0x4011ad in ???
#2  0x401272 in ???
#3  0x14fae276a50f in ???
#4  0x14fae276a5c8 in ???
#5  0x4010c4 in ???
#6  0x in ???
Illegal instruction (core dumped)

On the other hand, compiling with the system version (GNU Fortran (GCC)
12.3.1 20230508 (Red Hat 12.3.1-1)) or replacing the intrinsic repeat
with:

do kk = 1, pp
   cc (kk:kk) = " "
end do

both tests are ok. The error occurs on any of Intel or AMD computers,
e.g. in the present case:

$ lscpu
Architecture:   x86_64
   CPU op-mode(s):   32-bit, 64-bit
   Address sizes:46 bits physical, 48 bits virtual
   Byte Order:   Little Endian
CPU(s): 6
   On-line CPU(s) list:  0-5
Vendor ID:  GenuineIntel
   Model name:   Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz
 CPU family: 6
 Model:  45
 Thread(s) per core: 1
 Core(s) per socket: 6
 Socket(s):  1
 Stepping:   7
 BogoMIPS:   6400.22
Caches (sum of all):
   L1d:  192 KiB (6 instances)
   L1i:  192 KiB (6 instances)
   L2:   1.5 MiB (6 instances)
   L3:   12 MiB (1 instance)
NUMA:
   NUMA node(s): 1
   NUMA node0 CPU(s):0-5


By the way, I do not know if the -march=native flag or the intrinsic
repeat would be of deprecated use (or not)...


Regardless, we should never segfault.  Thanks for the code example. We 
need to get a bug report opened on this.  I am on travel this morning, 
but if I have time i will do so this afternnon if someone else does not 
beat me to it.


There were some recent patches in this area IIRC.

Jerry



beta gfortran 14.x.y (using -march=native and intrinsic repeat) gives a signal SIGILL

2023-08-11 Thread Jorge D'Elia via Fortran
Dear GFortran developers,

With the beta gfortran 14.x.y versions we are noticing some runtime 
errors in a production code. 

One type of runtime errors is related to the concurrent use of the 
intrinsic "repeat" when the source code is compiled with the 
flag -march=native, please, see below:

$ cat test.f90
program test
  implicit none
  integer  , parameter :: iin = kind (1)
  integer (iin), parameter :: pp = 32
  character (len=pp) :: cc
  cc (1:pp) = repeat (" ",pp) 
  write (*,*)" cc : " // cc
end program test

$ gfortran --version
GNU Fortran (GCC) 14.0.0 20230808 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

a) Compiling with the flag -mtune=native only, without -march=native, the test 
is ok:

$ gfortran -mtune=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og -o 
test.exe test.f90
$ test.exe 
  cc : 

b) However, compiling with the flag -march=native:

$ gfortran -march=native -fcheck=all -std=f2018 -Wall -Werror -Wextra -Og -o 
test.exe test.f90
$ test.exe 

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x14fae277fb1f in ???
#1  0x4011ad in ???
#2  0x401272 in ???
#3  0x14fae276a50f in ???
#4  0x14fae276a5c8 in ???
#5  0x4010c4 in ???
#6  0x in ???
Illegal instruction (core dumped)

On the other hand, compiling with the system version (GNU Fortran (GCC) 
12.3.1 20230508 (Red Hat 12.3.1-1)) or replacing the intrinsic repeat 
with:

do kk = 1, pp
  cc (kk:kk) = " "
end do

both tests are ok. The error occurs on any of Intel or AMD computers, 
e.g. in the present case:

$ lscpu 
Architecture:   x86_64
  CPU op-mode(s):   32-bit, 64-bit
  Address sizes:46 bits physical, 48 bits virtual
  Byte Order:   Little Endian
CPU(s): 6
  On-line CPU(s) list:  0-5
Vendor ID:  GenuineIntel
  Model name:   Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz
CPU family: 6
Model:  45
Thread(s) per core: 1
Core(s) per socket: 6
Socket(s):  1
Stepping:   7
BogoMIPS:   6400.22
Caches (sum of all):
  L1d:  192 KiB (6 instances)
  L1i:  192 KiB (6 instances)
  L2:   1.5 MiB (6 instances)
  L3:   12 MiB (1 instance)
NUMA:   
  NUMA node(s): 1
  NUMA node0 CPU(s):0-5


By the way, I do not know if the -march=native flag or the intrinsic 
repeat would be of deprecated use (or not)...


Regards.
Jorge.
--
CIMEC (UNL-CONICET), cimec.conicet.gov.ar, www.cimec.org.ar
Predio CONICET-Santa Fe, Colec. Ruta Nac. 168, 
Paraje El Pozo, 3000, Santa Fe, ARGENTINA. 
Tel +54-342-4511594/95 ext 7062, fax: +54-342-4511169