[Bug other/89702] New: 03 issue with SIGALRM causes program to SEGV on Solaris

2019-03-13 Thread karl.burgess at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89702

Bug ID: 89702
   Summary: 03 issue with SIGALRM causes program to SEGV on
Solaris
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: other
  Assignee: unassigned at gcc dot gnu.org
  Reporter: karl.burgess at oracle dot com
  Target Milestone: ---

Created attachment 45959
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45959&action=edit
Program source files

I have a program which compiles and works ok with -O1, but when I compile with
-O3 the program crashes.

The platform Solaris SunOS 5.10 is significant. The program works fine when
compiled with -O3 on Linux.

The key thing in the program to reproduce the crash is to have a SIGALRM signal
handled during the execution of the optimized function ConvertUTF8toUTF16().
Setting the input buffer large enough for that function to take longer to
execute is important.

Steps to reproduce the bug:

-bash-3.2$ uname -a
SunOS bazalgette.uk.oracle.com 5.10 Generic_150401-63 i86pc i386 i86pc Solaris
-bash-3.2$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/tarantella/libexec/gcc/i386-pc-solaris2.10/4.8.0/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.8.0/configure --with-fpmath=sse
--disable-sjlj-exceptions --with-gnu-as --with-as=/opt/tarantella/bin/as
--without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-system-zlib
--build=i386-pc-solaris2.10 --host=i386-pc-solaris2.10
--with-boot-ldflags=-Wl,-R,/opt/tarantella/lib --disable-werror
--disable-silent-rules --enable-multilib --prefix=/opt/tarantella
--with-gmp=/opt/tarantella/ --with-mpfr=/opt/tarantella/
--with-mpc=/opt/tarantella/ --enable-threads=posix --enable-libgomp
--enable-languages=c,c++ --with-cloog=/opt/tarantella/
--with-isl=/opt/tarantella/ --with-libelf=/opt/tarantella/ --disable-nls
--enable-cloog-backend=isl --disable-cloog-version-check
Thread model: posix
gcc version 4.8.0 (GCC)
-bash-3.2$ make
gcc -c main.c -O3 -ggdb -save-temps
gcc -c ConvertUTF.c -O3 -ggdb -save-temps
gcc -otest main.o ConvertUTF.o -O3 -ggdb -save-temps
-bash-3.2$ ./test
Clipboard data len 26214400
Segmentation Fault (core dumped)

The problem also occurs with gcc 8.3.0 on Solaris:

COLLECT_GCC=/export/home/kb161603/build_gcc/gcc/xgcc
Target: i386-pc-solaris2.10
Configured with: ../gcc-8.3.0/configure --with-mpc=/opt/tarantella
--with-gmp=/opt/tarantella --with-mpfr=/opt/tarantella : (reconfigured)
../gcc-8.3.0/configure --with-mpc=/opt/tarantella --with-gmp=/opt/tarantella
--with-mpfr=/opt/tarantella --enable-languages=c,c++
Thread model: posix
gcc version 8.3.0 (GCC)


The attachment gccbug.tar.gz contains the program source files, .i files and
Makefile:

-bash-3.2$ tar tvf gccbug.tar
-rw-r--r-- kb161603/other 9120 2019-03-12 15:59 ConvertUTF.c
-rw-r--r-- kb161603/other 6695 2019-03-07 11:29 ConvertUTF.h
-rw-r--r-- kb161603/other 5595 2019-03-13 13:59 ConvertUTF.i
-rw-r--r-- kb161603/other 6308 2019-03-13 13:59 ConvertUTF.o
-rw-r--r-- kb161603/other 26821 2019-03-13 13:59 ConvertUTF.s
-rw-r--r-- kb161603/other  1945 2019-03-12 16:14 main.c
-rw-r--r-- kb161603/other 38874 2019-03-13 13:59 main.i
-rw-r--r-- kb161603/other 10004 2019-03-13 13:59 main.o
-rw-r--r-- kb161603/other 37056 2019-03-13 13:59 main.s
-rw-r--r-- kb161603/other   268 2019-03-12 16:16 Makefile
-rwxr-xr-x kb161603/other 18936 2019-03-13 13:59 test

[Bug other/89702] 03 issue with SIGALRM causes program to SEGV on Solaris

2019-03-13 Thread karl.burgess at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89702

--- Comment #3 from Karl Burgess  ---
(In reply to Andrew Pinski from comment #2)
> >Solaris SunOS 5.10
> 
> This might mean it is a kernel issue too.
> What does gdb show when it crashes?
> info registers

Program terminated with signal 11, Segmentation fault.
#0  isLegalUTF8 (length=1, source=0x812e40f 'A' ...)
at ConvertUTF.c:131
131 switch (length) {
(gdb) where
#0  isLegalUTF8 (length=1, source=0x812e40f 'A' ...)
at ConvertUTF.c:131
#1  ConvertUTF8toUTF16 (sourceStart=sourceStart@entry=0x8047c70,
sourceEnd=sourceEnd@entry=0x9961740 "\001",
targetStart=targetStart@entry=0x8047c6c,
targetEnd=targetEnd@entry=0xcb61748, flags=flags@entry=lenientConversion)
at ConvertUTF.c:169
#2  0x08051311 in ConvertData (size=, pData=0x8061740)
at main.c:32
#3  main (argc=, argv=) at main.c:87
(gdb) info registers
eax0x0  0
ecx0x9afb0e6162509030
edx0x812e40f135455759
ebx0x1  1
esp0x8047c2a0x8047c2a
ebp0x812e4100x812e410
esi0x   -65536
edi0x41 65
eip0x8050ee80x8050ee8 
eflags 0x297[ CF PF AF SF IF ]
cs 0x3b 59
ss 0x43 67
ds 0x43 67
es 0x43 67
fs 0x0  0
gs 0x1c3451
(gdb)

[Bug other/89702] 03 issue with SIGALRM causes program to SEGV on Solaris

2019-03-14 Thread karl.burgess at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89702

--- Comment #4 from Karl Burgess  ---
(In reply to Richard Biener from comment #1)
> Note GCC 4.8.0 is no longer maintained (and is also the very first release
> off the GCC 4.8 branch with loads of bugfixes to come...).  Please update to
> a
> maintained version and try again - that would be at _least_ GCC 7.4, better
> GCC 8.3

The problem does not occur with GCC 8.3.0