[llvm-bugs] [Bug 51729] New: LLVM 13 Regression: __builtin_longjmp not working with -Oz

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 2 20:22:21 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51729

            Bug ID: 51729
           Summary: LLVM 13 Regression: __builtin_longjmp not working with
                    -Oz
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: xtkoba at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 25224
  --> https://bugs.llvm.org/attachment.cgi?id=25224&action=edit
Repro

Tested with 13.0.0-rc2 and 12.0.1. The repro could be made shorter.

Note that this issue is not necessarily specific to X86_64. A segfault is also
observed for ARM.

$ cat bsjlj.c

void foo(void **jb, int n);
void bar(int n);

void
bsj(void **jb, volatile int n)
{
  if (__builtin_setjmp(jb) == 0) {
    foo(jb, n);
  } else {
    bar(n);
  }
}

void
blj(void **jb)
{
  __builtin_longjmp(jb, 1);
}

int printf (const char *__restrict __format, ...);

void
foo(void **jb, int n)
{
  printf("foo: n = %d\n", n);
  blj(jb);
}

void
bar(int n)
{
  printf("bar: n = %d\n", n);
}

int
main(int argc, char *argv[] __attribute__((unused)))
{
  void *jb[5];
  bsj(jb, argc);
  bsj(jb, argc+1);

  return 0;
}

$ /usr/lib/llvm/12/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall
-Wextra -Wundef

$ ./a.out
foo: n = 1
bar: n = 1
foo: n = 2
bar: n = 2

$ /usr/lib/llvm/13/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall
-Wextra -Wundef

$ ./a.out
foo: n = 1
bar: n = 32764
Segmentation fault

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210903/c84f89ef/attachment.html>


More information about the llvm-bugs mailing list