public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
@ 2013-03-09 15:55 dacrick at gmail dot com
  2013-03-09 16:13 ` [Bug other/56579] " dacrick at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dacrick at gmail dot com @ 2013-03-09 15:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

             Bug #: 56579
           Summary: 4.8.0-20130303 g++ optimisation flags cause segfault
                    or different program output
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dacrick@gmail.com


Created attachment 29627
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29627
preprocessed version of paq8kx compression program source code

[My first GCC bug report so please kindly point out what
further information you may need.  I have tried to adhere
to the instructions at http://gcc.gnu.org/bugs/  Thanks.]

output of g++ -v:

Using built-in specs.
COLLECT_GCC=/usr/local/gcc-4.8-20130303/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8-20130303/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc-4.8-20130303
Thread model: posix
gcc version 4.8.0 20130303 (experimental) (GCC)


Running the compiled program ("./paq8kx somefile") when
compiled with -O3 or -Ofast results in a segfault.

Running when compiled with -O2 no longer segfaults but
produces different program output than expected.

-O1 segfaults

-O0 and Og run and create expected output.

(Note that the above -Ox behaviour is independent of
other compiler flags (including but not limited to -flto),
and can be achieved merely by using -Ox as the sole
differentiator.)


This compares to GCC 4.7.2 and my distro provided
4.4.6, which both produce binaries that do not segfault
at all and also generate identical program output
irrespective of -O option chosen at compile time.
Running the program author's pre-compiled binary
likewise matches 4.7.2 and 4.4.6 behaviour and output.


This is the only program that I've compiled using GCC
4.8 that does not run as expected; all others run fine.

It therefore appears that 4.8.0's optimizer is being
tripped up by something in paq8kx.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
  2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
@ 2013-03-09 16:13 ` dacrick at gmail dot com
  2013-03-09 16:22 ` markus at trippelsdorf dot de
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dacrick at gmail dot com @ 2013-03-09 16:13 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

dacrick at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dacrick at gmail dot com

--- Comment #1 from dacrick at gmail dot com 2013-03-09 16:12:34 UTC ---
Something in the back of my mind has since reminded
me of -fno-aggressive-loop-optimizations, and compiling
at (e.g.) -O3 using -fno-aggressive-loop-optimizations
no longer segfaults and produces the expected output.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
  2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
  2013-03-09 16:13 ` [Bug other/56579] " dacrick at gmail dot com
@ 2013-03-09 16:22 ` markus at trippelsdorf dot de
  2013-03-09 16:49 ` dacrick at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: markus at trippelsdorf dot de @ 2013-03-09 16:22 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

Markus Trippelsdorf <markus at trippelsdorf dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markus at trippelsdorf dot
                   |                            |de

--- Comment #2 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2013-03-09 16:22:19 UTC ---
(In reply to comment #1)
> Something in the back of my mind has since reminded
> me of -fno-aggressive-loop-optimizations, and compiling
> at (e.g.) -O3 using -fno-aggressive-loop-optimizations
> no longer segfaults and produces the expected output.

That most likely means that the programm is invoking undefined
behaviour and thus invalid.

A quick check with "clang++ -fsanitize=undefined" confirms this:
...
 paq8kx_v7.cpp:1795:13: fatal error: signed integer overflow: 707863021 * 8
cannot be represented in type 'int'


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
  2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
  2013-03-09 16:13 ` [Bug other/56579] " dacrick at gmail dot com
  2013-03-09 16:22 ` markus at trippelsdorf dot de
@ 2013-03-09 16:49 ` dacrick at gmail dot com
  2013-03-09 16:52 ` markus at trippelsdorf dot de
  2013-03-09 16:55 ` dacrick at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dacrick at gmail dot com @ 2013-03-09 16:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

--- Comment #3 from dacrick at gmail dot com 2013-03-09 16:48:40 UTC ---
(In reply to comment #2)
> That most likely means that the programm is invoking undefined
> behaviour and thus invalid.
> 
> A quick check with "clang++ -fsanitize=undefined" confirms this:
> ...
>  paq8kx_v7.cpp:1795:13: fatal error: signed integer overflow: 707863021 * 8
> cannot be represented in type 'int'

Thanks for your further investigation.

Clearly an error in the program code then.

Shall I change status of bug to RESOLVED? (assuming that's
how I close the bug?)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
  2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
                   ` (2 preceding siblings ...)
  2013-03-09 16:49 ` dacrick at gmail dot com
@ 2013-03-09 16:52 ` markus at trippelsdorf dot de
  2013-03-09 16:55 ` dacrick at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: markus at trippelsdorf dot de @ 2013-03-09 16:52 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

--- Comment #4 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2013-03-09 16:51:52 UTC ---
(In reply to comment #3)
> (In reply to comment #2)
> > That most likely means that the programm is invoking undefined
> > behaviour and thus invalid.
> > 
> > A quick check with "clang++ -fsanitize=undefined" confirms this:
> > ...
> >  paq8kx_v7.cpp:1795:13: fatal error: signed integer overflow: 707863021 * 8
> > cannot be represented in type 'int'
> 
> Thanks for your further investigation.
> 
> Clearly an error in the program code then.
> 
> Shall I change status of bug to RESOLVED? (assuming that's
> how I close the bug?)

Yes, RESOLVED->INVALID.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output
  2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
                   ` (3 preceding siblings ...)
  2013-03-09 16:52 ` markus at trippelsdorf dot de
@ 2013-03-09 16:55 ` dacrick at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dacrick at gmail dot com @ 2013-03-09 16:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56579

dacrick at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from dacrick at gmail dot com 2013-03-09 16:55:12 UTC ---
(In reply to comment #4)
> Yes, RESOLVED->INVALID.

many thanks.

Apologies for the false alarm / "noise", and thank you
again for your help and further diagnosis.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-09 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-09 15:55 [Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output dacrick at gmail dot com
2013-03-09 16:13 ` [Bug other/56579] " dacrick at gmail dot com
2013-03-09 16:22 ` markus at trippelsdorf dot de
2013-03-09 16:49 ` dacrick at gmail dot com
2013-03-09 16:52 ` markus at trippelsdorf dot de
2013-03-09 16:55 ` dacrick at gmail dot com

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).