From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB9693858427; Wed, 23 Mar 2022 03:46:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB9693858427 From: "ammarfaizi2 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/105032] New: Compiling inline ASM x86 causing GCC stuck in an endless loop with 100% CPU usage Date: Wed, 23 Mar 2022 03:46:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ammarfaizi2 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 03:46:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105032 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.o= rg/ 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$=20 ----------------------------------------- Reproducer: ----------------------------------------- #include #include #include #define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ long _ret; \ register long _num asm("eax") =3D (num); \ register long _arg1 asm("ebx") =3D (long)(arg1); \ register long _arg2 asm("ecx") =3D (long)(arg2); \ register long _arg3 asm("edx") =3D (long)(arg3); \ register long _arg4 asm("esi") =3D (long)(arg4); \ register long _arg5 asm("edi") =3D (long)(arg5); \ long _arg6 =3D (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" \ : "=3Da"(_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 >>=3D 12; return (void *)my_syscall6(__NR_mmap2, addr, length, prot, flags, f= d, offset); } int main(void) { __sys_mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); return 0; }=