This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/35249] New: gcc miscompiles emacs' src/intervals.c when using optimisation on solaris 8


I seem to have found a problem where gcc-4.1.2 and gcc-4.2.3 miscompile Emacs'
src/intervals.c when using optimisation on solaris 8.  

$ gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.8
Configured with: ../configure --enable-languages=c,c++
Thread model: posix
gcc version 4.2.3

I discovered it when investigating a problem whereby Emacs periodically
determined that some internal state was inconsistent.  Unfortunately, even
though I managed to find a scenario that reliably reproduced it, other people
were unable to reproduce it on other platforms.  So, at someone else's
suggestion, I investigated it as something specific to my environment.

Here's how to reproduce the problem.  Untar emacs-22.1, do a minimal configure
and build it on a solaris 2.8 box:

$ ./configure --with-x-toolkit=lucid --without-xaw3d --without-xpm
--without-jpeg --without-tiff --without-gif --without-png
--without-toolkit-scroll-bars
$ make

This builds everything with "-g -O2 -Wno-pointer-sign", giving the executable
src/emacs.

$ gdb src/emacs
GNU gdb 6.7.1
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...

Now put a breakpoint on the place where emacs is about to report that some
internal state is inconsistent.

(gdb) b intervals.c:794
Breakpoint 1 at 0x190db4: file intervals.c, line 794.
(gdb) r -Q
Starting program:
/homedev/marshals/ftp/emacs-22.2-pretests/gcc-4.2.3-g-O2/src/emacs -Q
warning: Temporarily disabling breakpoints for unloaded shared library
"/usr/lib/ld.so.1"

At this point, type C-x C-f src/intervals.c RET into the Emacs window.

Breakpoint 1, update_interval (i=0x81b6f4, pos=1771) at intervals.c:794
794                 error ("Point before start of properties");
(gdb) 

The breakpoint it hit, as emacs is about to report that some internal state is
inconsistent.  Now exit gdb and rebuild just intervals.c:

$ rm -f src/intervals.o
$ make CFLAGS=-g

This builds just intervals.o with "-g".  Repeat the above gdb session and you
will find that emacs does not hit the breakpoint, ie, the executable code is
functionally different.

I have reproduced this with gcc-4.1.2 and gcc-4.2.3.  I cannot reproduce it
using Sun Studio CC-5.7.  I also could not reproduce it on RHEL-5 with its
gcc-4.1.2, nor could a couple of other people who tried it on non-sparc
platforms.

I have also found that if I build everything else with "-g", but intervals.c
with "-g -O2", then I can reproduce this problem.  So, it seems specific to the
optimisation of intervals.c and specific to Solaris.  How could that be?

I appreciate that Emacs is not the smallest of test cases and I apologise in
advance for this crime.  Anything I can do to help determine the cause?


-- 
           Summary: gcc miscompiles emacs' src/intervals.c when using
                    optimisation on solaris 8
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: simon dot marshall at misys dot com
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]