public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug jit/100380] New: Segfault when using inline asm
@ 2021-05-02  1:51 bouanto at zoho dot com
  2021-05-02  1:54 ` [Bug jit/100380] " bouanto at zoho dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-05-02  1:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100380
           Summary: Segfault when using inline asm
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: bouanto at zoho dot com
  Target Milestone: ---

Created attachment 50729
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50729&action=edit
Reproducer for the bug

Hi.
The attached example produce a segfault when trying to compile code using
inline assembly.
Thanks.

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
@ 2021-05-02  1:54 ` bouanto at zoho dot com
  2021-05-02  2:20 ` bouanto at zoho dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-05-02  1:54 UTC (permalink / raw)
  To: gcc-bugs

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

Antoni <bouanto at zoho dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #50729|0                           |1
        is obsolete|                            |

--- Comment #1 from Antoni <bouanto at zoho dot com> ---
Created attachment 50730
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50730&action=edit
Fixed reproducer

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
  2021-05-02  1:54 ` [Bug jit/100380] " bouanto at zoho dot com
@ 2021-05-02  2:20 ` bouanto at zoho dot com
  2021-05-11 12:04 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-05-02  2:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Antoni <bouanto at zoho dot com> ---
Created attachment 50731
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50731&action=edit
Working code

So, the segfault seems to happen when creating the variable after creating the
extended asm expression.
Here's a working version of the code.

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
  2021-05-02  1:54 ` [Bug jit/100380] " bouanto at zoho dot com
  2021-05-02  2:20 ` bouanto at zoho dot com
@ 2021-05-11 12:04 ` marxin at gcc dot gnu.org
  2021-05-15 14:13 ` bouanto at zoho dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-11 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
           Assignee|dmalcolm at gcc dot gnu.org        |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-05-11

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
I'll take a look.

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
                   ` (2 preceding siblings ...)
  2021-05-11 12:04 ` marxin at gcc dot gnu.org
@ 2021-05-15 14:13 ` bouanto at zoho dot com
  2021-05-16 13:54 ` bouanto at zoho dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-05-15 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Antoni <bouanto at zoho dot com> ---
I just had a similar issue when developing a new feature for libgccjit and it
might be the same problem. If it is (I haven't checked in this case), here's
what's happening:

 * The asm is replayed.
 * The asm tries to access the replayed variable (which wasn't replayed yet
because it was created after the asm).
 * Segfault (the rest is not executed, but is shown to explain what's
happening)
 * The variable is replayed (too late because it was NULL when accessed by the
asm).

Again it's to be verified, and I'm not sure what should be the solution to this
problem because the mementos are replayed in the order they were created.

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
                   ` (3 preceding siblings ...)
  2021-05-15 14:13 ` bouanto at zoho dot com
@ 2021-05-16 13:54 ` bouanto at zoho dot com
  2021-08-16 11:31 ` marxin at gcc dot gnu.org
  2021-09-13 22:31 ` bouanto at zoho dot com
  6 siblings, 0 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-05-16 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Antoni <bouanto at zoho dot com> ---
I can confirm that the problem is indeed what I described in my previous post.

One solution would be to check if the rvalue was replayed (and if not, replay
it now), but that involves adding this check everywhere, so that seems very
invasive.

Do you think there's a better solution?

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
                   ` (4 preceding siblings ...)
  2021-05-16 13:54 ` bouanto at zoho dot com
@ 2021-08-16 11:31 ` marxin at gcc dot gnu.org
  2021-09-13 22:31 ` bouanto at zoho dot com
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-16 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|marxin at gcc dot gnu.org          |dmalcolm at gcc dot gnu.org

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Leaving to David..

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

* [Bug jit/100380] Segfault when using inline asm
  2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
                   ` (5 preceding siblings ...)
  2021-08-16 11:31 ` marxin at gcc dot gnu.org
@ 2021-09-13 22:31 ` bouanto at zoho dot com
  6 siblings, 0 replies; 8+ messages in thread
From: bouanto at zoho dot com @ 2021-09-13 22:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Antoni <bouanto at zoho dot com> ---
Since then, I found a workaround to fix the similar segfault in my other
feature.
It might work for solving this and goes like this:
instead of trying to access the rvalue when first replaying the asm, create an
intermediate memento that does the work of add_output_operand (and most likely
the other actions like add_input_operand).
It works since this memento will necessarily be created after both the asm and
the variable and thus, both will have been replayed when it's time to replay
the new 'add_output_operand' memento.

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

end of thread, other threads:[~2021-09-13 22:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-02  1:51 [Bug jit/100380] New: Segfault when using inline asm bouanto at zoho dot com
2021-05-02  1:54 ` [Bug jit/100380] " bouanto at zoho dot com
2021-05-02  2:20 ` bouanto at zoho dot com
2021-05-11 12:04 ` marxin at gcc dot gnu.org
2021-05-15 14:13 ` bouanto at zoho dot com
2021-05-16 13:54 ` bouanto at zoho dot com
2021-08-16 11:31 ` marxin at gcc dot gnu.org
2021-09-13 22:31 ` bouanto at zoho 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).