public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
@ 2014-08-27 10:55 justin.carveley at oracle dot com
  2014-08-27 10:56 ` [Bug target/62281] " justin.carveley at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

            Bug ID: 62281
           Summary: gcc doesn't conform to Solaris 32-bit ABI by expecting
                    16-byte stack alignment
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: justin.carveley at oracle dot com

Created attachment 33400
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33400&action=edit
Example 2: SSE vector load causes SEGV on callback from Xt timer

This is essentially a resubmission of bug 47842 "gcc forces 16-byte stack
alignment on Solaris i386, when SYSV requires word alignment".

As described in the above bug, changes to gcc for Linux x86 cause generated
code to assume a 16-byte preferred and incoming stack alignment. However, this
behaviour does not conform to the Solaris x86 (32-bit) ABI, which is still
based on http://www.sco.com/developers/devspecs/abi386-4.pdf and only specifies
that the stack be 32-bit word aligned.

PR 47842 was closed due to a lack of test cases. Here, therefore, are two test
cases that demonstrate the problem:


Example 1: Mixing 32-bit modules compiled with the Solaris Studio 12.3 and gcc:

Using:
- Solaris Studio compiler from
http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-141149.html
- gcc 4.8.0 (stable) or gcc 4.9.0 (unstable) package from
http://www.opencsw.org/
  or gcc 4.9.1 built from tarball

Files: x.c, y.c, build

Result:

GNU gdb (GDB) 7.6
Copyright (C) 2013 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 "i386-pc-solaris2.10".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/home/justin/tmp/xy...done.
(gdb) r    
Starting program: /export/home/justin/tmp/xy 

Program received signal SIGSEGV, Segmentation fault.
0x080509db in _mm_set_epi8 (__q00=1 '\001', __q01=1 '\001', __q02=1 '\001', 
    __q03=1 '\001', __q04=1 '\001', __q05=1 '\001', __q06=1 '\001', 
    __q07=1 '\001', __q08=1 '\001', __q09=1 '\001', __q10=1 '\001', 
    __q11=1 '\001', __q12=1 '\001', __q13=1 '\001', __q14=1 '\001', 
    __q15=1 '\001')
    at
/opt/tarantella/lib/gcc/i386-pc-solaris2.10/4.8.0/include/emmintrin.h:602
602       return __extension__ (__m128i)(__v16qi){
(gdb) where
#0  0x080509db in _mm_set_epi8 (__q00=1 '\001', __q01=1 '\001', 
    __q02=1 '\001', __q03=1 '\001', __q04=1 '\001', __q05=1 '\001', 
    __q06=1 '\001', __q07=1 '\001', __q08=1 '\001', __q09=1 '\001', 
    __q10=1 '\001', __q11=1 '\001', __q12=1 '\001', __q13=1 '\001', 
    __q14=1 '\001', __q15=1 '\001')
    at
/opt/tarantella/lib/gcc/i386-pc-solaris2.10/4.8.0/include/emmintrin.h:602
#1  _mm_set1_epi8 (__A=1 '\001')
    at
/opt/tarantella/lib/gcc/i386-pc-solaris2.10/4.8.0/include/emmintrin.h:637
#2  test_sse () at x.c:5
#3  0x08050a1b in main (argc=1, argv=0x8047d74) at y.c:5
(gdb) 


Example 2: libXt timer callback

Using:
- gcc 4.8.0 (stable) or gcc 4.9.0 (unstable) packages from
http://www.opencsw.org/
- or gcc 4.9.1 from tarball

File: xt.c

Result:
The stack becomes only 4-byte aligned on callback from Xt.

GNU gdb (GDB) 7.6
Copyright (C) 2013 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 "i386-pc-solaris2.10".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/home/justin/tmp/xt...done.
(gdb) r
Starting program: /export/home/justin/tmp/xt 

Program received signal SIGSEGV, Segmentation fault.
0x08050e97 in _mm_set_epi8 (__q00=1 '\001', __q01=1 '\001', __q02=1 '\001', 
    __q03=1 '\001', __q04=1 '\001', __q05=1 '\001', __q06=1 '\001', 
    __q07=1 '\001', __q08=1 '\001', __q09=1 '\001', __q10=1 '\001', 
    __q11=1 '\001', __q12=1 '\001', __q13=1 '\001', __q14=1 '\001', 
    __q15=1 '\001')
    at /opt/csw/lib/gcc/i386-pc-solaris2.10/4.8.0/include/emmintrin.h:602
602       return __extension__ (__m128i)(__v16qi){
(gdb) info reg ebp
ebp            0x8047c74        0x8047c74
(gdb) fr 1
#1  _mm_set1_epi8 (__A=1 '\001')
    at /opt/csw/lib/gcc/i386-pc-solaris2.10/4.8.0/include/emmintrin.h:637
637       return _mm_set_epi8 (__A, __A, __A, __A, __A, __A, __A, __A,
(gdb) info reg ebp
ebp            0x8047c74        0x8047c74
(gdb) fr 2
#2  timer_callback (client_data=0x0, id=0x8047d10) at xt.c:10
10          __m128i b = _mm_set1_epi8(1);
(gdb) info reg ebp
ebp            0x8047c74        0x8047c74
(gdb) fr 3
#3  0xfef46e29 in XtAppProcessEvent () from /usr/lib/libXt.so.4
(gdb) info reg ebp
ebp            0x8047d18        0x8047d18
(gdb) fr 4
#4  0x08050efc in main (argc=1, argv=0x8047d74) at xt.c:17
17          XtAppProcessEvent(app, XtIMTimer);
(gdb) info reg ebp
ebp            0x8047d4c        0x8047d4c
(gdb) 

I believe the problem was fixed for the limited case of Solaris 9 x86 in bug
60107. However, the analysis for this fix seems slightly off. It infers that,
because Solaris 10 creates outgoing thread stacks aligned on 16 bytes, the
32-bit ABI has changed to 16-byte stack alignment on this platform, which isn't
correct.

I suggest -mincoming-stack-boundary=2 should be the default for all 32-bit
Solaris binaries.


Workarounds:
1. __attribute__((force_align_arg_pointer)) at all entry points to gcc
generated code,
2. Compile all gcc code with -mincoming-stack-boundary=2.


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
@ 2014-08-27 10:56 ` justin.carveley at oracle dot com
  2014-08-27 10:57 ` justin.carveley at oracle dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #1 from Justin Carveley <justin.carveley at oracle dot com> ---
Created attachment 33401
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33401&action=edit
Example 2: Preprocessed source


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
  2014-08-27 10:56 ` [Bug target/62281] " justin.carveley at oracle dot com
@ 2014-08-27 10:57 ` justin.carveley at oracle dot com
  2014-08-27 10:58 ` justin.carveley at oracle dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #2 from Justin Carveley <justin.carveley at oracle dot com> ---
Created attachment 33402
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33402&action=edit
Example 1: gcc compiled module performing sse vector load


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
  2014-08-27 10:56 ` [Bug target/62281] " justin.carveley at oracle dot com
  2014-08-27 10:57 ` justin.carveley at oracle dot com
@ 2014-08-27 10:58 ` justin.carveley at oracle dot com
  2014-08-27 10:59 ` justin.carveley at oracle dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #3 from Justin Carveley <justin.carveley at oracle dot com> ---
Created attachment 33403
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33403&action=edit
Example 1: Solaris studio compiled module: main()


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (3 preceding siblings ...)
  2014-08-27 10:59 ` justin.carveley at oracle dot com
@ 2014-08-27 10:59 ` justin.carveley at oracle dot com
  2014-08-29 14:37 ` ro at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #5 from Justin Carveley <justin.carveley at oracle dot com> ---
Created attachment 33405
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33405&action=edit
Example 1: build script


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (2 preceding siblings ...)
  2014-08-27 10:58 ` justin.carveley at oracle dot com
@ 2014-08-27 10:59 ` justin.carveley at oracle dot com
  2014-08-27 10:59 ` justin.carveley at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: justin.carveley at oracle dot com @ 2014-08-27 10:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #4 from Justin Carveley <justin.carveley at oracle dot com> ---
Created attachment 33404
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33404&action=edit
Example 1: preprocessed source


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (4 preceding siblings ...)
  2014-08-27 10:59 ` justin.carveley at oracle dot com
@ 2014-08-29 14:37 ` ro at gcc dot gnu.org
  2014-08-29 15:16 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ro at gcc dot gnu.org @ 2014-08-29 14:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ro at gcc dot gnu.org
   Target Milestone|---                         |5.0

--- Comment #6 from Rainer Orth <ro at gcc dot gnu.org> ---
I've been seeing the same issue in PR middle-end/61949, but only on Solaris 10,
not S11, and the failures have been intermittent (i.e. happened during one
bootstrap,
but were gone a week later).

Regarding

> I believe the problem was fixed for the limited case of Solaris 9 x86 in bug 
> 60107. However, the analysis for this fix seems slightly off. It infers that,
> because Solaris 10 creates outgoing thread stacks aligned on 16 bytes, the
> 32-bit ABI has changed to 16-byte stack alignment on this platform, which isn't
> correct.

I believe the i386 psABI is irrelevant here: while it requires word alignment,
it
doesn't preclude that Solaris guarantees a stricter alignment, which from what
I've seen both S10 and S11 do.

> I suggest -mincoming-stack-boundary=2 should be the default for all 32-bit
> Solaris binaries.

Before making any changes in this area, I'd like word from the responsible libc
engineer (Roger Faulkner probably) what various Solaris versions do and don't
guarantee.

  Rainer


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (5 preceding siblings ...)
  2014-08-29 14:37 ` ro at gcc dot gnu.org
@ 2014-08-29 15:16 ` joseph at codesourcery dot com
  2015-04-22 12:00 ` jakub at gcc dot gnu.org
  2015-07-16  9:13 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2014-08-29 15:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
FWIW, I recommended to Sun in Mar 2006 that the kernel should ensure 
16-byte alignment for both signal handlers and process startup (apparently 
this resulted in Sun bug 6397812, "Problem with stack alignment for signal 
delivery on AMD64").  (This does not of course mean that the ABI ended up 
with such an alignment requirement at interface boundaries in general.)


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (6 preceding siblings ...)
  2014-08-29 15:16 ` joseph at codesourcery dot com
@ 2015-04-22 12:00 ` jakub at gcc dot gnu.org
  2015-07-16  9:13 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 12:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.0                         |5.2

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.


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

* [Bug target/62281] gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment
  2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
                   ` (7 preceding siblings ...)
  2015-04-22 12:00 ` jakub at gcc dot gnu.org
@ 2015-07-16  9:13 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62281

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


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

end of thread, other threads:[~2015-07-16  9:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-27 10:55 [Bug target/62281] New: gcc doesn't conform to Solaris 32-bit ABI by expecting 16-byte stack alignment justin.carveley at oracle dot com
2014-08-27 10:56 ` [Bug target/62281] " justin.carveley at oracle dot com
2014-08-27 10:57 ` justin.carveley at oracle dot com
2014-08-27 10:58 ` justin.carveley at oracle dot com
2014-08-27 10:59 ` justin.carveley at oracle dot com
2014-08-27 10:59 ` justin.carveley at oracle dot com
2014-08-29 14:37 ` ro at gcc dot gnu.org
2014-08-29 15:16 ` joseph at codesourcery dot com
2015-04-22 12:00 ` jakub at gcc dot gnu.org
2015-07-16  9:13 ` rguenth at gcc dot gnu.org

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