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

core: fix ASAN_START_SWITCH_FIBER() usage #8977

Conversation

Gumix
Copy link
Contributor

@Gumix Gumix commented Aug 11, 2023

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

@Gumix Gumix requested a review from a team as a code owner August 11, 2023 19:14
@coveralls
Copy link

coveralls commented Aug 11, 2023

Coverage Status

coverage: 86.178% (-0.003%) from 86.181% when pulling 4e414eb on Gumix:iverbin/gh-321-segfault-while-running-tests-against-asan-build-clang-16 into a4e21fe
on tarantool:master
.

@Gumix Gumix requested a review from locker August 11, 2023 19:29
src/lib/core/fiber.h Outdated Show resolved Hide resolved
src/lib/core/fiber.c Outdated Show resolved Hide resolved
src/lib/core/fiber.c Outdated Show resolved Hide resolved
@locker locker assigned Gumix and unassigned locker Aug 14, 2023
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
@Gumix Gumix force-pushed the iverbin/gh-321-segfault-while-running-tests-against-asan-build-clang-16 branch from bd0d217 to 4e414eb Compare August 14, 2023 11:53
@Gumix Gumix requested a review from locker August 14, 2023 12:11
@Gumix Gumix assigned locker and unassigned Gumix Aug 14, 2023
@locker locker added the full-ci Enables all tests for a pull request label Aug 15, 2023
@locker locker merged commit 72a6abe into tarantool:master Aug 15, 2023
82 checks passed
@locker
Copy link
Member

locker commented Aug 15, 2023

Cherry-picked to 2.11 and 2.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Enables all tests for a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault while running tests against ASAN build (Clang-16)
4 participants