public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105960] New: Crash in 32-bit mode
@ 2022-06-13 19:54 terra at gnome dot org
  2022-06-13 20:00 ` [Bug target/105960] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: terra at gnome dot org @ 2022-06-13 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105960
           Summary: Crash in 32-bit mode
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terra at gnome dot org
  Target Milestone: ---

Created attachment 53130
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53130&action=edit
Source files and compile script

The attached archive shows a crash when running 32-bit binaries compiled with
gcc 12.1

I am preliminarily blaming the C compiler.




0. Unpack tar file

1. Edit "compile" to point at the desired compiler

2. ./compile

3. ./crash32

Expected: immediate return
Observed: Segmentation fault (core dumped)

(gdb) where
#0  0xf7fc73d0 in *ABS*@plt () from /home/welinder/crash32/liboink32.so
#1  0x0804841d in main ()


Observations (probably more "anecdote" than "data"):

* Doesn't happen in 64-bit mode
* Doesn't happen without optimization
* The shared library appears to be a required part
* The use target_clones appears to be a required part
* This did not happen with gcc 11.1


# uname -a
Linux xxxxxxxxxx 5.3.18-150300.59.63-default #1 SMP Tue Apr 5 12:47:31 UTC 2022
(d77db66) x86_64 x86_64 x86_64 GNU/Linux


# /usr/local/products/gcc/12.1.0/bin/gcc --version
gcc (GCC) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

* [Bug target/105960] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
@ 2022-06-13 20:00 ` pinskia at gcc dot gnu.org
  2022-06-13 20:00 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-13 20:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
COMPILE="$CC -m32 -O2 -I. -Wall"

# Preprocessed files were created thus:
# $COMPILE -E crash32.c > crash32-preprocessed.c
# $COMPILE -E expref.c > expref-preprocessed.c

$COMPILE -c -o crash32.o crash32.c
$COMPILE -c -o expref.o expref.c

$CC -m32 -o liboink32.so   -shared expref.o

$CC -m32 -o crash32 -g crash32.o $PWD/liboink32.so -lm
```

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

* [Bug target/105960] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
  2022-06-13 20:00 ` [Bug target/105960] " pinskia at gcc dot gnu.org
@ 2022-06-13 20:00 ` pinskia at gcc dot gnu.org
  2022-06-13 20:06 ` terra at gnome dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-13 20:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> $COMPILE -c -o crash32.o crash32.c
> $COMPILE -c -o expref.o expref.c

> $CC -m32 -o liboink32.so   -shared expref.o

You didn't use -fPIC which is required if you are compiling a shared library.

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

* [Bug target/105960] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
  2022-06-13 20:00 ` [Bug target/105960] " pinskia at gcc dot gnu.org
  2022-06-13 20:00 ` pinskia at gcc dot gnu.org
@ 2022-06-13 20:06 ` terra at gnome dot org
  2022-06-13 20:08 ` terra at gnome dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: terra at gnome dot org @ 2022-06-13 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

M Welinder <terra at gnome dot org> changed:

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

--- Comment #3 from M Welinder <terra at gnome dot org> ---
This happens with -fPIC added to COMPILE too.  (It got dropped somewhere in the
minimization of the sample.)

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

* [Bug target/105960] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (2 preceding siblings ...)
  2022-06-13 20:06 ` terra at gnome dot org
@ 2022-06-13 20:08 ` terra at gnome dot org
  2022-06-14  8:30 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: terra at gnome dot org @ 2022-06-13 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from M Welinder <terra at gnome dot org> ---
And added to the link lines too, btw.

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

* [Bug target/105960] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (3 preceding siblings ...)
  2022-06-13 20:08 ` terra at gnome dot org
@ 2022-06-14  8:30 ` rguenth at gcc dot gnu.org
  2022-06-14  8:31 ` [Bug target/105960] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-14  8:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|x86_64                      |i?86-*-*
   Last reconfirmed|                            |2022-06-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |hjl.tools at gmail dot com

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Something is wrong with either ld.so or GCC.  We end up with

        .globl  exp_ref
        .type   exp_ref, @function
exp_ref:
.LFB1:
        .cfi_startproc
        pushl   %ebx
        .cfi_def_cfa_offset 8
        .cfi_offset 3, -8
        popl    %ebx
        .cfi_restore 3
        .cfi_def_cfa_offset 4
        jmp     expfull_ref@PLT

^^^ this crashes

        .type   expfull_ref, @gnu_indirect_function
        .set    expfull_ref,expfull_ref.resolver

        .type   expfull_ref.resolver, @function
expfull_ref.resolver:
.LFB4:
        .cfi_startproc
        pushl   %ebx

but expfull_ref isn't .globl!?


#define TARGET_CLONES  __attribute__((target_clones("default","fma")))
TARGET_CLONES
static inline double
expfull_ref(double x)
{
  return __builtin_pow(x, 0.1234);
}

double
exp_ref(double x)
{
  return expfull_ref(x);
}

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (4 preceding siblings ...)
  2022-06-14  8:30 ` rguenth at gcc dot gnu.org
@ 2022-06-14  8:31 ` rguenth at gcc dot gnu.org
  2022-06-14 14:18 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-14  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Keywords|                            |needs-bisection, wrong-code
            Summary|Crash in 32-bit mode        |[12/13 Regression] Crash in
                   |                            |32-bit mode
      Known to work|                            |11.3.0
      Known to fail|                            |12.1.0
   Target Milestone|---                         |12.2

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (5 preceding siblings ...)
  2022-06-14  8:31 ` [Bug target/105960] [12/13 Regression] " rguenth at gcc dot gnu.org
@ 2022-06-14 14:18 ` hjl.tools at gmail dot com
  2022-06-14 15:02 ` hjl.tools at gmail dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2022-06-14 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
This is caused by r12-5771.

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (6 preceding siblings ...)
  2022-06-14 14:18 ` hjl.tools at gmail dot com
@ 2022-06-14 15:02 ` hjl.tools at gmail dot com
  2022-06-14 17:22 ` wwcsmail at gmail dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2022-06-14 15:02 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |hjl.tools at gmail dot com

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
Created attachment 53135
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53135&action=edit
A patch

Try this.

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (7 preceding siblings ...)
  2022-06-14 15:02 ` hjl.tools at gmail dot com
@ 2022-06-14 17:22 ` wwcsmail at gmail dot com
  2022-06-20 15:26 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: wwcsmail at gmail dot com @ 2022-06-14 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

Wolfgang Wander <wwcsmail at gmail dot com> changed:

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

--- Comment #8 from Wolfgang Wander <wwcsmail at gmail dot com> ---
Thanks H.J,

tried and this indeed fixes the issue!

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (8 preceding siblings ...)
  2022-06-14 17:22 ` wwcsmail at gmail dot com
@ 2022-06-20 15:26 ` cvs-commit at gcc dot gnu.org
  2022-06-21 17:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-20 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5

commit r13-1180-gfe9765c0b97e6b4ce2cd226631d329fc05ba2aa5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jun 14 08:20:16 2022 -0700

    i386: Disallow sibcall for calling ifunc functions with PIC register

    Disallow siball when calling ifunc functions with PIC register so that
    PIC register can be restored.

    gcc/

            PR target/105960
            * config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
            false if PIC register is used when calling ifunc functions.

    gcc/testsuite/

            PR target/105960
            * gcc.target/i386/pr105960.c: New test.

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (9 preceding siblings ...)
  2022-06-20 15:26 ` cvs-commit at gcc dot gnu.org
@ 2022-06-21 17:45 ` cvs-commit at gcc dot gnu.org
  2022-07-15  9:00 ` marxin at gcc dot gnu.org
  2022-07-15 18:07 ` hjl.tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-21 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:2474c8e09a93027cde39ecb6a53742142c8496ed

commit r12-8501-g2474c8e09a93027cde39ecb6a53742142c8496ed
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jun 14 08:20:16 2022 -0700

    i386: Disallow sibcall for calling ifunc functions with PIC register

    Disallow siball when calling ifunc functions with PIC register so that
    PIC register can be restored.

    gcc/

            PR target/105960
            * config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
            false if PIC register is used when calling ifunc functions.

    gcc/testsuite/

            PR target/105960
            * gcc.target/i386/pr105960.c: New test.

    (cherry picked from commit fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5)

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (10 preceding siblings ...)
  2022-06-21 17:45 ` cvs-commit at gcc dot gnu.org
@ 2022-07-15  9:00 ` marxin at gcc dot gnu.org
  2022-07-15 18:07 ` hjl.tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-15  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
Can we close it now?

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

* [Bug target/105960] [12/13 Regression] Crash in 32-bit mode
  2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
                   ` (11 preceding siblings ...)
  2022-07-15  9:00 ` marxin at gcc dot gnu.org
@ 2022-07-15 18:07 ` hjl.tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2022-07-15 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #12 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed.

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

end of thread, other threads:[~2022-07-15 18:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 19:54 [Bug c/105960] New: Crash in 32-bit mode terra at gnome dot org
2022-06-13 20:00 ` [Bug target/105960] " pinskia at gcc dot gnu.org
2022-06-13 20:00 ` pinskia at gcc dot gnu.org
2022-06-13 20:06 ` terra at gnome dot org
2022-06-13 20:08 ` terra at gnome dot org
2022-06-14  8:30 ` rguenth at gcc dot gnu.org
2022-06-14  8:31 ` [Bug target/105960] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-06-14 14:18 ` hjl.tools at gmail dot com
2022-06-14 15:02 ` hjl.tools at gmail dot com
2022-06-14 17:22 ` wwcsmail at gmail dot com
2022-06-20 15:26 ` cvs-commit at gcc dot gnu.org
2022-06-21 17:45 ` cvs-commit at gcc dot gnu.org
2022-07-15  9:00 ` marxin at gcc dot gnu.org
2022-07-15 18:07 ` hjl.tools 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).