public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66226] New: Incorrect code generation ppc, later assignment causes calling argument corruption
@ 2015-05-20 19:54 steven.deller at ois dot com
  2015-05-20 20:35 ` [Bug target/66226] " pinskia at gcc dot gnu.org
  2015-05-22  2:36 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: steven.deller at ois dot com @ 2015-05-20 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66226
           Summary: Incorrect code generation ppc, later assignment causes
                    calling argument corruption
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steven.deller at ois dot com
  Target Milestone: ---

Created attachment 35581
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35581&action=edit
Interim file

In the attached code, a simple assignment "rp = res" after the call to
getaddrinfo causes the arguments to getaddrinfo to be invalid, most likely the
hints argument, since making that argument NULL also allows the compiled code
to execute successfully.

An assignment following a call should not cause different behavior within the
call.

This only fails on the PowerPC compiler (I only have tested it on AIX).  It
fails for versions 4.7.3, 4.8.3 and this reported 4.9.3 version.

The gcc compiler is the version supplied from AdaCore with the GNAT products. 
I do not have access to the build information for the compiler.

Regards,
Steven Deller
410-757-6924

tga.c source:
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>

int main(int argc, char **argv) {
        struct addrinfo *res;
        struct addrinfo hints;
        int rc;
        struct addrinfo *rp;

        hints.ai_family = AF_INET;      /* IPv4 only */
        hints.ai_socktype = SOCK_DGRAM;
        hints.ai_flags = 0;
        hints.ai_protocol = 0;
        hints.ai_canonname = NULL;
        hints.ai_addr = NULL;
        hints.ai_next = NULL;

        rc = getaddrinfo("aix7", NULL, &hints, &res);  // if hints is "NULL",
runs fine

        rp = res;  // rc=11 with this in.  Comment out and rc=0.

        printf ("rc=%d\n", rc);
        return 0;
}


output from "gcc -v -save-temps tga.c" compilation:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/lto-wrapper
Target: powerpc-ibm-aix7.1.0.0
Configured with: ../src/configure --enable-languages=ada,c --with-gnu-as
--with-gnu-ld --with-dwarf2 --disable-shared
--disable-build-poststage1-with-cxx --disable-libsanitizer --disable-libcilkrts
--with-bugurl=URL:mailto:report@adacore.com --disable-nls
--without-libiconv-prefix --disable-libmudflap --disable-libstdcxx-pch
--disable-libada --enable-checking=release --enable-multilib --disable-plugin
--with-mpfr=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/mpfr/install
--with-gmp=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/gmp/install
--with-mpc=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/mpc/install
--with-build-time-tools=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix/gcc/build/buildtools/bin
--prefix=/usr/local/gnat --target=powerpc-ibm-aix7.1.0.0
--host=powerpc-ibm-aix7.1.0.0 --build=i686-pc-linux-gnu
Thread model: aix
gcc version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps'

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/cc1
-E -quiet -v -iprefix
/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/
tga.c -fpch-preprocess -o tga.i
ignoring nonexistent directory
"/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../../powerpc-ibm-aix7.1.0.0/include"
ignoring duplicate directory
"/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include"
ignoring duplicate directory
"/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include-fixed"
ignoring nonexistent directory
"/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../../powerpc-ibm-aix7.1.0.0/include"
#include "..." search starts here:
#include <...> search starts here:

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include-fixed
 /usr/local/include
 /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps'

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/cc1
-fpreprocessed tga.i -quiet -dumpbase tga.c -auxbase tga -version -o tga.s
GNU C (GCC) version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118)
(powerpc-ibm-aix7.1.0.0)
        compiled by GNU C version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118),
GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768
GNU C (GCC) version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118)
(powerpc-ibm-aix7.1.0.0)
        compiled by GNU C version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118),
GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768
Compiler executable checksum: 1afb14c19ac4a4577644783d23418153
COLLECT_GCC_OPTIONS='-v' '-save-temps'

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/as
-v -u -mpwr4 -many -o tga.o tga.s
GNU assembler version 2.24.51 (powerpc-ibm-aix7.1.0.0) using BFD version (GNU
Binutils) 2.24.51.20140908
COMPILER_PATH=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/
LIBRARY_PATH=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps'

/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/collect2
-bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect /lib/crt0.o
/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/crtcxa.o
-L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3
-L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc
-L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../..
tga.o
/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/libgcc.a
-lc
/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/libgcc.a


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

* [Bug target/66226] Incorrect code generation ppc, later assignment causes calling argument corruption
  2015-05-20 19:54 [Bug c/66226] New: Incorrect code generation ppc, later assignment causes calling argument corruption steven.deller at ois dot com
@ 2015-05-20 20:35 ` pinskia at gcc dot gnu.org
  2015-05-22  2:36 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-05-20 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This sounds more likegetaddrinfo is over writing past the variable hints.


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

* [Bug target/66226] Incorrect code generation ppc, later assignment causes calling argument corruption
  2015-05-20 19:54 [Bug c/66226] New: Incorrect code generation ppc, later assignment causes calling argument corruption steven.deller at ois dot com
  2015-05-20 20:35 ` [Bug target/66226] " pinskia at gcc dot gnu.org
@ 2015-05-22  2:36 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-05-22  2:36 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Both AIX and POSIX require that:

  In this hints structure, all members other than ai_flags, ai_eflags
ai_family, ai_socktype, and ai_protocol must be zero or a NULL pointer.

The program fails to set to zero the ai_addrlen member which causes the
function to fail (with both gcc and xlc).  Once ai_addrlen is set to zero, the
program behaves as you expect.


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

end of thread, other threads:[~2015-05-22  2:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 19:54 [Bug c/66226] New: Incorrect code generation ppc, later assignment causes calling argument corruption steven.deller at ois dot com
2015-05-20 20:35 ` [Bug target/66226] " pinskia at gcc dot gnu.org
2015-05-22  2:36 ` msebor 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).