-
Notifications
You must be signed in to change notification settings - Fork 0
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
Segfault while running tests against ASAN build (Clang-16) #321
Comments
To reproduce the issue, it's suffice to start tarantool in the interactive mode and then exit. The problem is buried somewhere in the diff --git a/src/main.cc b/src/main.cc
index 5c7587135915..40b89f6c9368 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -162,7 +162,7 @@ on_shutdown_f(va_list ap)
while (!is_shutting_down)
fiber_yield();
- if (trigger_fiber_run(&box_on_shutdown_trigger_list, NULL,
+ if (0 && trigger_fiber_run(&box_on_shutdown_trigger_list, NULL,
on_shutdown_trigger_timeout) != 0) {
say_error("on_shutdown triggers failed");
diag_log(); |
This change also helps... diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index 958e4a02f..4ab7bd282 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -710,6 +710,7 @@ fiber_yield(void)
cord->fiber = callee;
callee->flags = (callee->flags & ~FIBER_IS_READY) | FIBER_IS_RUNNING;
+ __asm__ __volatile__("": : :"memory");
ASAN_START_SWITCH_FIBER(asan_state,
(caller->flags & FIBER_IS_DEAD) == 0,
callee->stack, This also helps: diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index 958e4a02f..3e717d64e 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -711,7 +711,7 @@ fiber_yield(void)
callee->flags = (callee->flags & ~FIBER_IS_READY) | FIBER_IS_RUNNING;
ASAN_START_SWITCH_FIBER(asan_state,
- (caller->flags & FIBER_IS_DEAD) == 0,
+ true,
callee->stack,
callee->stack_size);
coro_transfer(&caller->ctx, &callee->ctx); A similar crash: google/sanitizers#189 (comment) |
So, what happens when Ctrl+D is pressed:
With
TLDR: We said to ASAN that we wouldn't switch back to a fiber, but switched to its recycled incarnation. |
The `__sanitizer_start_switch_fiber()` function takes a pointer as the first argument to store the current fake stack if there is one (it is necessary when stack-use-after-return detection is enabled). When leaving a fiber definitely, NULL must be passed so that the fake stack is destroyed. Before this patch, NULL was passed for dead fibers, however this is wrong for dead fibers that are recycled and resumed. In such cases ASAN destroys the fake stack, and the fiber crashes trying to use it in `fiber_yield()` upon return from `coro_transfer()`. Closes tarantool/tarantool-qa#321 NO_DOC=bugfix NO_TEST=tested by test-release-asan workflow
The `__sanitizer_start_switch_fiber()` function takes a pointer as the first argument to store the current fake stack if there is one (it is necessary when stack-use-after-return detection is enabled). When leaving a fiber definitely, NULL must be passed so that the fake stack is destroyed. Before this patch, NULL was passed for dead fibers, however this is wrong for dead fibers that are recycled and resumed. In such cases ASAN destroys the fake stack, and the fiber crashes trying to use it in `fiber_yield()` upon return from `coro_transfer()`. Closes tarantool/tarantool-qa#321 NO_DOC=bugfix NO_TEST=tested by test-release-asan workflow (cherry picked from commit 72a6abe)
The `__sanitizer_start_switch_fiber()` function takes a pointer as the first argument to store the current fake stack if there is one (it is necessary when stack-use-after-return detection is enabled). When leaving a fiber definitely, NULL must be passed so that the fake stack is destroyed. Before this patch, NULL was passed for dead fibers, however this is wrong for dead fibers that are recycled and resumed. In such cases ASAN destroys the fake stack, and the fiber crashes trying to use it in `fiber_yield()` upon return from `coro_transfer()`. Closes tarantool/tarantool-qa#321 NO_DOC=bugfix NO_TEST=tested by test-release-asan workflow (cherry picked from commit 72a6abe)
Tarantool
Steps to reproduce
Open
.test.mk
file and removerun-luajit-test
target from L112. Save and exit.The command above runs one test only. If you want to get all failures, remove
TEST_RUN_EXTRA_PARAMS=app/fiber.test.lua
from the command.Expected result: Test passed.
Actual result:
The text was updated successfully, but these errors were encountered: