public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105032] New: Compiling inline ASM x86 causing GCC stuck in an endless loop with 100% CPU usage
@ 2022-03-23  3:46 ammarfaizi2 at gmail dot com
  2022-03-23  3:52 ` [Bug middle-end/105032] " pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: ammarfaizi2 at gmail dot com @ 2022-03-23  3:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105032
           Summary: Compiling inline ASM x86 causing GCC stuck in an
                    endless loop with 100% CPU usage
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ammarfaizi2 at gmail dot com
  Target Milestone: ---

Full story:
https://lore.kernel.org/lkml/9cfcb296-9dfe-aef1-4209-20a3a95c50ba@gnuweeb.org/

Compiling inline ASM x86 causing GCC stuck in an endless loop with 100% CPU
usage.

-----------------------------------------
ammarfaizi2@integral2:/tmp$ gcc --version
gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
Copyright (C) 2021 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.

ammarfaizi2@integral2:/tmp$ gcc -m32 -o test test.c # stuck here...
^C
ammarfaizi2@integral2:/tmp$ 
-----------------------------------------



Reproducer:
-----------------------------------------
#include <sys/mman.h>
#include <stddef.h>
#include <syscall.h>

#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6)            \
({                                                                      \
        long _ret;                                                      \
        register long _num  asm("eax") = (num);                         \
        register long _arg1 asm("ebx") = (long)(arg1);                  \
        register long _arg2 asm("ecx") = (long)(arg2);                  \
        register long _arg3 asm("edx") = (long)(arg3);                  \
        register long _arg4 asm("esi") = (long)(arg4);                  \
        register long _arg5 asm("edi") = (long)(arg5);                  \
        long _arg6 = (long)(arg6); /* Always be in memory */            \
                                                                        \
        asm volatile (                                                  \
                "pushl  %[_arg6]\n\t"                                   \
                "pushl  %%ebp\n\t"                                      \
                "movl   4(%%esp), %%ebp\n\t"                            \
                "int    $0x80\n\t"                                      \
                "popl   %%ebp\n\t"                                      \
                "addl   $4,%%esp\n\t"                                   \
                : "=a"(_ret)                                            \
                : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3),        \
                  "r"(_arg4),"r"(_arg5), [_arg6]"m"(_arg6)              \
                : "memory", "cc"                                        \
        );                                                              \
        _ret;                                                           \
})


static void *__sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
                        off_t offset)
{
        offset >>= 12;
        return (void *)my_syscall6(__NR_mmap2, addr, length, prot, flags, fd,
                                   offset);
}

int main(void)
{
        __sys_mmap(NULL, 0x1000, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
        return 0;
}

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

end of thread, other threads:[~2022-08-02  6:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23  3:46 [Bug c/105032] New: Compiling inline ASM x86 causing GCC stuck in an endless loop with 100% CPU usage ammarfaizi2 at gmail dot com
2022-03-23  3:52 ` [Bug middle-end/105032] " pinskia at gcc dot gnu.org
2022-03-23  4:05 ` crazylht at gmail dot com
2022-03-23  9:24 ` jakub at gcc dot gnu.org
2022-03-23  9:28 ` jakub at gcc dot gnu.org
2022-03-23 13:22 ` ammarfaizi2 at gmail dot com
2022-03-23 13:27 ` ammarfaizi2 at gmail dot com
2022-03-23 13:50 ` jakub at gcc dot gnu.org
2022-03-23 19:24 ` hjl.tools at gmail dot com
2022-03-29 12:49 ` vmakarov at gcc dot gnu.org
2022-03-30 17:02 ` vmakarov at gcc dot gnu.org
2022-03-30 17:10 ` cvs-commit at gcc dot gnu.org
2022-03-30 17:12 ` vmakarov at gcc dot gnu.org
2022-04-01 14:21 ` cvs-commit at gcc dot gnu.org
2022-07-28 18:43 ` hjl.tools at gmail dot com
2022-08-02  6:18 ` andrey.vihrov 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).