Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM 13 Regression: __builtin_longjmp not working with -Oz #51071

Open
xtkoba mannequin opened this issue Sep 3, 2021 · 5 comments
Open

LLVM 13 Regression: __builtin_longjmp not working with -Oz #51071

xtkoba mannequin opened this issue Sep 3, 2021 · 5 comments
Labels
bugzilla Issues migrated from bugzilla llvm Umbrella label for LLVM issues

Comments

@xtkoba
Copy link
Mannequin

xtkoba mannequin commented Sep 3, 2021

Bugzilla Link 51729
Version trunk
OS Linux
Blocks #50580 #51489
Attachments Repro, Repro (with workaround added), bsjlj.ll diff with D109248 applied
CC @aeubanks,@DimitryAndric,@RKSimon,@tstellar

Extended Description

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
@DimitryAndric
Copy link
Collaborator

DimitryAndric commented Sep 4, 2021

Note this appears to have regressed with 669ddd1e9b12 ("Turn on the new pass manager by default"), at least that is what I see when doing a bisection.

However, this commit only turned on the new pass manager. If I compile the example with -flegacy-pass-manager, it does not segfault.

And vice versa, if I use any clang before 669ddd1 with -fno-legacy-pass-manager or -fexperimental-new-pass-manager, it does segfault. I went back to the llvmorg-10-init branch point, but even that makes it crash.

Ergo, there is something about the new pass manager that influences this particular crash scenario.

@xtkoba
Copy link
Mannequin Author

xtkoba mannequin commented Sep 4, 2021

Thanks for the investigation, Dimitry.

Now I am pretty much sure that the switch of the default pass manager just manifests a long-standing bug in __builtin_setjmp.

Should this be resolved as a duplicate of #49578 ?

@DimitryAndric
Copy link
Collaborator

Thanks for the investigation, Dimitry.

Now I am pretty much sure that the switch of the default pass manager just
manifests a long-standing bug in __builtin_setjmp.

Should this be resolved as a duplicate of #49578 ?

I would keep this one as it seems more general (bug 50234 appears to refer specifically to PowerPC, at first), and more people are CC'd on it.

@tstellar
Copy link
Collaborator

mentioned in issue #51489

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@asl asl added this to the LLVM 13.0.1 release milestone Dec 12, 2021
@tstellar
Copy link
Collaborator

The deadline for requesting fixes for the release has passed. This bug is being removed from the LLVM 13.0.1 release milestone. If you have a fix or think this bug is important enough to block the release, please explain why in a comment and add the bug back to the LLVM 13.0.1 release milestone.

@tstellar tstellar removed this from the LLVM 13.0.1 release milestone Dec 21, 2021
@Endilll Endilll changed the title LLVM 13 Regression: __builtin_longjmp not working with -Oz LLVM 13 Regression: __builtin_longjmp not working with -Oz Jul 18, 2024
@Endilll Endilll added the llvm Umbrella label for LLVM issues label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm Umbrella label for LLVM issues
Projects
None yet
Development

No branches or pull requests

4 participants