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

ASAN: Support coroutine context switching and stack tracing #4153

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

winlinvip
Copy link
Member

@winlinvip winlinvip commented Aug 22, 2024

For coroutine, we should use __sanitizer_start_switch_fiber which similar toVALGRIND_STACK_REGISTER, see google/sanitizers#189 (comment) for details. If not fix this, asan will output warning:

==72269==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x00016f638000; bottom 0x000106bec000; size: 0x000068a4c000 (1755627520)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189

It will cause asan failed to get the stack, see research/st/asan-switch.cpp for example:

==71611==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x000103600733 at pc 0x0001009d3d7c bp 0x000100b4bd40 sp 0x000100b4bd38
WRITE of size 1 at 0x000103600733 thread T0
    #0 0x1009d3d78 in foo(void*) asan-switch.cpp:13

After fix this issue, it should provide the full stack when crashing:

==73437==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x000103300733 at pc 0x000100693d7c bp 0x00016f76f550 sp 0x00016f76f548
WRITE of size 1 at 0x000103300733 thread T0
    #0 0x100693d78 in foo(void*) asan-switch.cpp:13
    #1 0x100693df4 in main asan-switch.cpp:23
    #2 0x195aa20dc  (<unknown module>)

For primordial coroutine, if not set the stack by st_set_primordial_stack, then the stack is NULL and asan can't get the stack tracing. Note that it's optional and only make it fail to display the stack information, no other errors.

@winlinvip winlinvip linked an issue Aug 22, 2024 that may be closed by this pull request
@winlinvip winlinvip merged commit 8f48a0e into ossrs:develop Aug 22, 2024
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR: LeakSanitizer: detected memory leaks for daemon
2 participants