-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Coroutine miscompilation on arm64 leading to invalid memory access #51843
Labels
Comments
We were running into the same problem. I put up a fix in https://reviews.llvm.org/D140231 |
@llvm/issue-subscribers-backend-aarch64 |
@llvm/issue-subscribers-coroutines |
I pushed a fix with https://reviews.llvm.org/D140231 |
Closed
6 tasks
mmaslankaprv
added a commit
to mmaslankaprv/redpanda
that referenced
this issue
Feb 27, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com>
mmaslankaprv
added a commit
to mmaslankaprv/redpanda
that referenced
this issue
Feb 27, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com>
NyaliaLui
pushed a commit
to NyaliaLui/redpanda
that referenced
this issue
Feb 28, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com>
NyaliaLui
pushed a commit
to NyaliaLui/redpanda
that referenced
this issue
Feb 28, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com>
6 tasks
NyaliaLui
pushed a commit
to NyaliaLui/redpanda
that referenced
this issue
Feb 28, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com>
vbotbuildovich
pushed a commit
to vbotbuildovich/redpanda
that referenced
this issue
Feb 28, 2023
Converted `AlterPartitionReassignmentRequest` handler to use continuation chain. This change was required becuase of bug in clang (llvm/llvm-project#51843) Fixes: redpanda-data#9089 Signed-off-by: Michal Maslanka <michal@redpanda.com> (cherry picked from commit 5b2f95b)
michoecho
added a commit
to michoecho/scylla
that referenced
this issue
Aug 1, 2023
llvm/llvm-project#51843 causes clang-15 to miscompile some coroutines. We hit it with describe_ring() on ARM. The fmt::to_string() call inside the coroutine triggers the bug. The workaround is to move the call out of the coroutine. Fixes scylladb#14412
michoecho
added a commit
to michoecho/scylla
that referenced
this issue
Aug 1, 2023
llvm/llvm-project#51843 causes clang-15 to miscompile some coroutines. We hit it with describe_ring() on ARM. The fmt::to_string() call inside the coroutine triggers the bug. The workaround is to move the call out of the coroutine. Fixes scylladb#14412
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extended Description
Hi, the bug is best described by the (very simple) attached test case: there is a coroutine do_run with an infinite loop containing a suspension point. Variable val is created on the stack inside the loop. Address of this variable is then taken, stuck into the args struct and passed to the func function which dereferences the pointer and returns the result. We then check that the returned value is equal to the original value of val. The code in main() simply resumes a coroutine a few times.
When compiled on arm64 this results in invalid memory accesses by the program (bogus values returned from func/use-of-uninitialized-value under MSan).
Checked this with clang-13 downloaded from https://apt.llvm.org/focal/ although earlier versions exhibit the same behavior.
Compilation command: clang++-13 -std=c++20 -stdlib=libc++ -fcoroutines-ts -O2 test_coro.cc
Here is the compiler explorer link (compiled with a slightly older clang): https://godbolt.org/z/sxraMMvP5
AFAICT miscompilation is already present in the generated LLVM IR (https://gist.github.com/ztlpn/453b1f906e5f838fa6e47434b03c65e6): the args struct is placed into the coroutine frame and args.value_ is incorrectly initialized with a pointer to memory allocated in the stack frame of the coroutine entry function (line 27, 38). By contrast, if I compile on x86_64, memory for val is correctly allocated in the stack frame of the coroutine resume function and the program doesn't crash.
The text was updated successfully, but these errors were encountered: