-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
support swapcontext #189
Comments
Reported by |
Reported by |
Reported by |
Reported by |
Reported by - _Attachment: [test_coroutine.cpp](https://storage.googleapis.com/google-code-attachments/address-sanitizer/issue-189/comment-6/test_coroutine.cpp)_ |
Reported by
|
Reported by |
I ran into this bug as well and made a test case. It's derived from the test suite in a fuzzer I'm writing. https://github.com/2trill2spill/nextgen . This was tested on Mac OSX 10.11.12, and below is the output from
And the test case, which was compiled with
|
2trill2spill, why is the previous comment related to this bug? |
The error message I get from running the test case points to this page, so I assumed that It was the same issue.
|
I don't see such message on Linux, so it might be a OSX-specific issue, |
Summary:ASAN needs to know about the stack extents. Currently it has no knowledge of fibers and so it can give false positives, particularly in cases of no-return (think exceptions). See: google/sanitizers#189 This change along with a related ASAN diff fixes that, and I've verified it fixes false positive test failures I'm seeing when throws happen from fibers. Also rips out some hacks that attempted to work around the limitations of ASAN these changes should fix. This change depends on: D3017630 D2952854 D3017619 And will also depend on rollout of libasan.so to /usr/local/fbcode platform dirs on all machines. Reviewed By: andriigrynenko Differential Revision: D2952899 fb-gh-sync-id: 19da779227c6c0f30c5755806325aa4cba364cfe shipit-source-id: 19da779227c6c0f30c5755806325aa4cba364cfe
Can anyone explain how facebook/folly@2ea64dd works? I could not find anything like "__asan_enter_fiber"? Is there something like |
Since there is nothing on the Internet about those functions, I guess that facebook has a fork of clang where they have implemented them. I tried to implement the functions myself here, but I have very little knowledge of how things work, feedback is welcome. Note that the function prototypes are a little different from those used by folly. I tested this code with an implementation of coroutines on top of boost context v2, the warning about handle_no_return has indeed disappeared and it seems to work. |
Thank you! I will try your modified version as soon as possible. You just include the "asan_interface_internal.h" header in your binary or do you use the approach from facebook/folly@2ea64dd (dlsym)? |
I only did some tests for the moment where I just declared the functions in my project: extern "C"
{
void __asan_enter_fiber(void const* stack_top, void const* stack_bottom);
void __asan_exit_fiber();
} Of course this fails to link if I don't compile with asan. I think folly's approach (with the weak symbol attributes and the fallback on dlsym) should work too. |
FYI my patch finally passed review (a lot of things were fixed in the meantime), http://llvm.org/viewvc/llvm-project?view=revision&revision=273260 . Now let's wait for clang 3.9 :) |
That's great news! Thank you very much for your effort! 👍 |
I just ran into this issue. I see the solution is to notify asan if switching stacks? I'm implementing coroutines. |
@ioquatix on gcc? Whoa! I think gcc 7 and latest clang have better support for makecontext and friends. |
Yes, the idea is to annotate your code to notify asan when you switch context. You can find some documentation here https://github.com/llvm-mirror/compiler-rt/blob/master/include/sanitizer/common_interface_defs.h#L166 and an example in the tests https://github.com/llvm-mirror/compiler-rt/blob/master/test/asan/TestCases/Linux/swapcontext_annotation.cc . Since the test is still there, I don't think swapcontext has got any more support for asan. |
https://github.com/orgs/kurocha/repositories?q=coroutine&type=all&language=&sort= for all native implementations. |
Thanks! |
Coroutine transfer is a simple operation, it's a function call and return with a stack swap in the middle. Any implementation that makes it more complicated than that is wrong. IMHO :) |
You are right. :) |
…detect mods to free blocks SwiftCoroutineDemo(39856,0x11266e600) malloc: nano zone abandoned due to inability to preallocate reserved vm space. DispatchQueue::scheduleTask() <OS_dispatch_queue_main: com.apple.main-thread> SharedCoroutineDispatcher::getFreeQueue(SwiftCoroutine.SharedCoroutineDispatcher) CoroutineContext::init(stackSize=196608, guardPage=true, SwiftCoroutine.CoroutineContext) returnEnv = 0x000060f0000042d0 stack = 0x000000010effb000 SharedCoroutineQueue::start(SwiftCoroutine.SharedCoroutineQueue) CoroutineContext::start(SwiftCoroutine.CoroutineContext) enter CoroutineContext::stackTop(SwiftCoroutine.CoroutineContext) 0x000000010f02b000 CoroutineContext::start(Optional(0x00006060000b8400)) block enter ==39856==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x7ff7b7045000; bottom 0x00010f028000; size: 0x7ff6a801d000 (140697357373440) False positive error reports may follow For details see google/sanitizers#189 CoroutineContext::start(SwiftCoroutine.CoroutineContext) leave DispatchQueue::scheduleTask() <OS_dispatch_queue_main: com.apple.main-thread> SharedCoroutineDispatcher::getFreeQueue(SwiftCoroutine.SharedCoroutineDispatcher) SharedCoroutineQueue::start(SwiftCoroutine.SharedCoroutineQueue) CoroutineContext::stackTop(SwiftCoroutine.CoroutineContext) 0x000000010f02b000 ================================================================= ==39856==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00010f029ec1 at pc 0x00010949d77d bp 0x7ff7b7040e90 sp 0x7ff7b7040650 READ of size 4416 at 0x00010f029ec1 thread T0 #0 0x10949d77c in wrap_memcpy+0x16c (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x1977c) belozierov#1 0x109ef7f83 in SharedCoroutine.saveStack() SharedCoroutine.swift:79 belozierov#2 0x109eff514 in SharedCoroutineQueue.start(dispatcher:scheduler:task:) SharedCoroutineQueue.swift:39 belozierov#3 0x109efc229 in closure belozierov#1 in SharedCoroutineDispatcher.execute(on:task:) SharedCoroutineDispatcher.swift:27 belozierov#4 0x109ee7ed9 in OS_dispatch_queue.scheduleTask(_:) CoroutineScheduler+DispatchQueue.swift:16 belozierov#5 0x109ee88ad in protocol witness for CoroutineScheduler.scheduleTask(_:) in conformance OS_dispatch_queue <compiler-generated> belozierov#6 0x109efbf48 in SharedCoroutineDispatcher.execute(on:task:) SharedCoroutineDispatcher.swift:26 belozierov#7 0x109ee3616 in CoroutineScheduler._startCoroutine(_:) CoroutineScheduler.swift:51 belozierov#8 0x109ee3c78 in CoroutineScheduler.startCoroutine(in:task:) CoroutineScheduler.swift:69 belozierov#9 0x108ebe2ed in AppDelegate.test() AppDelegate.swift:43 belozierov#10 0x108ebdd77 in AppDelegate.application(_:didFinishLaunchingWithOptions:) AppDelegate.swift:18 belozierov#11 0x108ebe4b7 in @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) <compiler-generated> belozierov#12 0x7fff2509a592 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]+0xd5 (UIKitCore:x86_64+0xcd7592) belozierov#13 0x7fff2509c283 in -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]+0x101f (UIKitCore:x86_64+0xcd9283) belozierov#14 0x7fff250a1c23 in -[UIApplication _runWithMainScene:transitionContext:completion:]+0x4a5 (UIKitCore:x86_64+0xcdec23) belozierov#15 0x7fff246124a2 in -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]+0xb2 (UIKitCore:x86_64+0x24f4a2) belozierov#16 0x7fff2509e2ac in -[UIApplication _compellApplicationLaunchToCompleteUnconditionally]+0x3a (UIKitCore:x86_64+0xcdb2ac) belozierov#17 0x7fff2509e64b in -[UIApplication _run]+0x391 (UIKitCore:x86_64+0xcdb64b) belozierov#18 0x7fff250a32b4 in UIApplicationMain+0x64 (UIKitCore:x86_64+0xce02b4) belozierov#19 0x7fff59d55cc1 in UIApplicationMain(_:_:_:_:)+0x61 (libswiftUIKit.dylib:x86_64+0x21cc1) belozierov#20 0x108ebf357 in static UIApplicationDelegate.main() <compiler-generated> belozierov#21 0x108ebf2a0 in static AppDelegate.$main() AppDelegate.swift:11 belozierov#22 0x108ebfc77 in main <compiler-generated> belozierov#23 0x1090f8f20 in start_sim+0x9 (dyld_sim:x86_64+0x1f20) belozierov#24 0x1125f352d (<unknown module>) 0x00010f029ec1 is located 192193 bytes inside of 200704-byte region [0x00010effb000,0x00010f02c000) allocated by thread T0 here: #0 0x1094c7bb3 in wrap_posix_memalign+0xb3 (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x43bb3) belozierov#1 0x7fff30c9e62c in swift_slowAlloc+0x4c (libswiftCore.dylib:x86_64+0x30762c) belozierov#2 0x109ede243 in CoroutineContext.init(stackSize:guardPage:) CoroutineContext.swift:32 belozierov#3 0x109eddc1f in CoroutineContext.__allocating_init(stackSize:guardPage:) CoroutineContext.swift belozierov#4 0x109efe985 in SharedCoroutineQueue.init(stackSize:) SharedCoroutineQueue.swift:28 belozierov#5 0x109efe5c3 in SharedCoroutineQueue.__allocating_init(stackSize:) SharedCoroutineQueue.swift belozierov#6 0x109efcb3d in SharedCoroutineDispatcher.getFreeQueue() SharedCoroutineDispatcher.swift:38 belozierov#7 0x109efc20d in closure belozierov#1 in SharedCoroutineDispatcher.execute(on:task:) SharedCoroutineDispatcher.swift:27 belozierov#8 0x109ee7ed9 in OS_dispatch_queue.scheduleTask(_:) CoroutineScheduler+DispatchQueue.swift:16 belozierov#9 0x109ee88ad in protocol witness for CoroutineScheduler.scheduleTask(_:) in conformance OS_dispatch_queue <compiler-generated> belozierov#10 0x109efbf48 in SharedCoroutineDispatcher.execute(on:task:) SharedCoroutineDispatcher.swift:26 belozierov#11 0x109ee3616 in CoroutineScheduler._startCoroutine(_:) CoroutineScheduler.swift:51 belozierov#12 0x109ee3c78 in CoroutineScheduler.startCoroutine(in:task:) CoroutineScheduler.swift:69 belozierov#13 0x108ebe2ed in AppDelegate.test() AppDelegate.swift:43 belozierov#14 0x108ebdd77 in AppDelegate.application(_:didFinishLaunchingWithOptions:) AppDelegate.swift:18 belozierov#15 0x108ebe4b7 in @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) <compiler-generated> belozierov#16 0x7fff2509a592 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]+0xd5 (UIKitCore:x86_64+0xcd7592) belozierov#17 0x7fff2509c283 in -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]+0x101f (UIKitCore:x86_64+0xcd9283) belozierov#18 0x7fff250a1c23 in -[UIApplication _runWithMainScene:transitionContext:completion:]+0x4a5 (UIKitCore:x86_64+0xcdec23) belozierov#19 0x7fff246124a2 in -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]+0xb2 (UIKitCore:x86_64+0x24f4a2) belozierov#20 0x7fff2509e2ac in -[UIApplication _compellApplicationLaunchToCompleteUnconditionally]+0x3a (UIKitCore:x86_64+0xcdb2ac) belozierov#21 0x7fff2509e64b in -[UIApplication _run]+0x391 (UIKitCore:x86_64+0xcdb64b) belozierov#22 0x7fff250a32b4 in UIApplicationMain+0x64 (UIKitCore:x86_64+0xce02b4) belozierov#23 0x7fff59d55cc1 in UIApplicationMain(_:_:_:_:)+0x61 (libswiftUIKit.dylib:x86_64+0x21cc1) belozierov#24 0x108ebf357 in static UIApplicationDelegate.main() <compiler-generated> belozierov#25 0x108ebf2a0 in static AppDelegate.$main() AppDelegate.swift:11 belozierov#26 0x108ebfc77 in main <compiler-generated> belozierov#27 0x1090f8f20 in start_sim+0x9 (dyld_sim:x86_64+0x1f20) belozierov#28 0x1125f352d (<unknown module>) SUMMARY: AddressSanitizer: stack-buffer-overflow (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x1977c) in wrap_memcpy+0x16c Shadow bytes around the buggy address: 0x0001344ad380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad3a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad3b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad3c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0001344ad3d0: 00 00 00 00 f1 f1 f1 f1[01]f3 f3 f3 00 00 00 00 0x0001344ad3e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad3f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0001344ad420: 00 00 00 00 00 00 00 00 00 00 00 00 ca ca ca ca Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==39856==ABORTING AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report. (lldb)
Currently the sanitizer can't handle user thread properly. See google/sanitizers#189 for details. Close it temporarily to make CI sound.
Hi everyone, @ioquatix I met an issue when I tried to enable Asan in the c program using swapcontext function, are you free to provide some advice? The following are the details: With the help of ___sanitizer_start_switch_fiber/_sanitizer_finish_switch_fiber, even if I turned on the Asan, my program worked fine in jumpping from one to another coroutine(like main thread to coroutine func2, coroutine func2 to coroutine func1), but as soon as I try to restore the old coroutine by jumping back to it, Asan stops working(stack-buffer-overflow can not be detected). And I noticed that the argument func2_thread_stack below got nothing all the time:
Could you give me some advice? Sincerely, |
I need to share my experience with boost-asio and asan briefly for all other fellows that are me three days ago. If this is your problem: "You need to make asan and boost-asio with coroutines get along" then your are in for a treat. I put some pieces together but it is essentially no-brainer, boost-asio does not have the incentives to move to coroutine2 chriskohlhoff/asio#603 but thanks to https://github.com/cbodley/spawn (a stand- Obviously you need to build boost with asan support as mentioned here boostorg/coroutine#30 (comment)
And simplest part build your project with |
Thanks to @ioquatix , the compatible issue between ASAN and swapcontext is solved in my program. He was very friendly and very patient, and he taught me a lot about asan. I have compiled some of the lessons he taught me so that more people like me can learn from it: Compatible issue between ASAN and swapcontext() Under this constraint, if function swapcontext() is introduced in your program, there will be some false positives reported after coroutine was changed. 2.Mechanism of asan And to understand why these false positives occur, we need to learn how asan works: 3.Way to make swapcontext() compatible with asan Therefore, we need to find a way to notify ASAN before/after we exchange the fiber. To make things easier, I recommend adding For this fake_stack:
And when we try to jump to new(target) coroutine by executing swapcontext(), we need to store the fake_stack of old(current) fiber, so that when we try to return to the old fiber, we can restore the stack of old fiber with the fake_stack we ever stored before. Here introduce two function provided by ASAN to manage the fake_stack:
The implementation of these two function is in here: https://github.com/llvm/llvm-project/blob/a2ef44a5d65932c7bb0f483217826856325b60df/compiler-rt/lib/asan/asan_thread.cpp#L526-L551 From the source code, we can see that, __sanitizer_start_switch_fiber will assign the fake_stack IF and ONLY IF you provide a pointer. This is how I handle swapcontext() issue:
ASAN only cares about tracking the stack swapping, so as long as you wrap the stack exchange operation (coroutine transfer) correctly, ASAN should work well with swapcontext(). |
I wonder if the above comment can be added to the Wiki? |
New checks in abseil revealed: 13: [/home/nwatkins/src/redpanda/vbuild/debug/clang/rp_deps_install/include/absl/container/internal/raw_hash_set.h : 1259] RAW: Invalid iterator comparison. Comparing iterator with an end() iterator from a different hashtable. 13: ==1795828==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x7fa25cf16000; bottom 0x7ffd07b05000; size: 0xffffffa555411000 (-389411696640) 13: False positive error reports may follow 13: For details see google/sanitizers#189 13: unknown location(0): fatal error: in "complex_uuid_types_test": signal: SIGABRT (application abort requested) Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
We also encountered the problem: Stack trace with symbols: Thread 2 (LWP 1236467):
#0 __sanitizer::atomic_exchange<__sanitizer::atomic_uint32_t> (mo=__sanitizer::memory_order_acquire, v=2, a=0x640000001b00)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:61
#1 __sanitizer::BlockingMutex::Lock (this=this@entry=0x640000001b00) at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_linux.cc:618
#2 0x00007f0c9958f37d in __sanitizer::GenericScopedLock<__sanitizer::BlockingMutex>::GenericScopedLock (mu=0x640000001b00, this=<synthetic pointer>)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_mutex.h:183
#3 __sanitizer::SizeClassAllocator64<__asan::AP64>::GetFromAllocator (this=this@entry=0x7f0c996c7e40 <__asan::instance>, stat=stat@entry=0x7f0c7c67bc40, class_id=class_id@entry=36,
chunks=chunks@entry=0x7f0c7c677330, n_chunks=n_chunks@entry=8)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_allocator_primary64.h:126
#4 0x00007f0c9958f4ac in __sanitizer::SizeClassAllocator64LocalCache<__sanitizer::SizeClassAllocator64<__asan::AP64> >::Refill (this=this@entry=0x7f0c7c66e0e0, c=c@entry=0x7f0c7c677320,
allocator=allocator@entry=0x7f0c996c7e40 <__asan::instance>, class_id=class_id@entry=36)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_allocator_local_cache.h:105
#5 0x00007f0c99593a78 in __sanitizer::SizeClassAllocator64LocalCache<__sanitizer::SizeClassAllocator64<__asan::AP64> >::Allocate (class_id=36, allocator=0x7f0c996c7e40 <__asan::instance>,
this=0x7f0c7c66e0e0) at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_common.h:439
#6 __sanitizer::CombinedAllocator<__sanitizer::SizeClassAllocator64<__asan::AP64>, __sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator64<__asan::AP64> >, __sanitizer::LargeMmapAllocator<__asan::AsanMapUnmapCallback, __sanitizer::ReturnNullOrDieOnFailure> >::Allocate (alignment=1, size=8192, cache=0x7f0c7c66e0e0, this=0x7f0c996c7e40 <__asan::instance>)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_allocator_combined.h:60
#7 __asan::QuarantineCallback::Allocate (size=8192, this=<synthetic pointer>) at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_allocator.cc:163
#8 __sanitizer::QuarantineCache<__asan::QuarantineCallback>::Enqueue (size=32, ptr=0x60300013a7f0, cb=..., this=0x7f0c7c66e060)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_quarantine.h:212
#9 __sanitizer::Quarantine<__asan::QuarantineCallback, __asan::AsanChunk>::Put (size=32, ptr=0x60300013a7f0, cb=..., c=0x7f0c7c66e060, this=0x7f0c998c80b8 <__asan::instance+2097784>)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_quarantine.h:102
#10 __asan::Allocator::QuarantineChunk (stack=0x60300013a800, ptr=0x60300013a800, m=0x60300013a7f0, this=0x7f0c996c7e40 <__asan::instance>)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_allocator.cc:564
#11 __asan::Allocator::Deallocate (this=this@entry=0x7f0c996c7e40 <__asan::instance>, ptr=ptr@entry=0x60300013a800, delete_size=delete_size@entry=0, stack=stack@entry=0x7f0c7ce83c70,
alloc_type=alloc_type@entry=__asan::FROM_MALLOC) at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_allocator.cc:609
#12 0x00007f0c9958e657 in __asan::asan_free (ptr=ptr@entry=0x60300013a800, stack=stack@entry=0x7f0c7ce83c70, alloc_type=alloc_type@entry=__asan::FROM_MALLOC)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_allocator.cc:803
#13 0x00007f0c9964ffdb in __interceptor_free (ptr=0x60300013a800) at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:69
#14 0x00007f0c98d254bd in __pthread_attr_destroy (attr=attr@entry=0x7f0c7ce84510) at pthread_attr_destroy.c:38
#15 0x00007f0c9966c892 in __sanitizer::GetThreadStackTopAndBottom (at_initialization=at_initialization@entry=false, stack_top=stack_top@entry=0x7f0c7ce845a0,
stack_bottom=stack_bottom@entry=0x7f0c7ce845a8) at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:110
#16 0x00007f0c9966cbf3 in __sanitizer::GetThreadStackAndTls (main=<optimized out>, stk_addr=stk_addr@entry=0x7f0c7c66e020, stk_size=stk_size@entry=0x7f0c7ce845f8,
tls_addr=tls_addr@entry=0x7f0c7c66e040, tls_size=tls_size@entry=0x7f0c7ce845f0)
at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:415
#17 0x00007f0c9965e7bf in __asan::AsanThread::SetThreadStackAndTls (this=this@entry=0x7f0c7c66e000, options=<optimized out>)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_thread.h:80
#18 0x00007f0c9965ea31 in __asan::AsanThread::Init (this=this@entry=0x7f0c7c66e000, options=options@entry=0x0)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_thread.cc:224
#19 0x00007f0c9965ee34 in __asan::AsanThread::ThreadStart (this=0x7f0c7c66e000, os_id=1236467, signal_thread_is_registered=0x7f0c830bfda8)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_thread.cc:241
#20 0x00007f0c98d23c79 in start_thread (arg=0x7f0c7ce8a700) at pthread_create.c:486
#21 0x00007f0c986d7a4f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (LWP 1236463):
#0 __sanitizer::internal_sched_yield () at /gcc8_x86_64/src/gcc/libsanitizer/sanitizer_common/sanitizer_syscall_linux_x86_64.inc:18
#1 0x00007f0c995b7f45 in __interceptor_pthread_create (thread=thread@entry=0x60f0000000e0, attr=<optimized out>, attr@entry=0x0,
start_routine=start_routine@entry=0x3502c00 <bvar::detail::SamplerCollector::sampling_thread(void*)>, arg=arg@entry=0x60f000000040)
at /gcc8_x86_64/src/gcc/libsanitizer/asan/asan_interceptors.cc:242
#2 0x00000000035021d3 in bvar::detail::SamplerCollector::create_sampling_thread (this=0x60f000000040)
at code/third_party/submodule/brpc/src/bvar/detail/sampler.cpp:104
#3 bvar::detail::SamplerCollector::after_forked_as_child (this=0x60f000000040) at code/third_party/submodule/brpc/src/bvar/detail/sampler.cpp:104
#4 bvar::detail::SamplerCollector::child_callback_atfork () at code/third_party/submodule/brpc/src/bvar/detail/sampler.cpp:86
#5 0x00007f0c986e4cf8 in __run_fork_handlers (who=who@entry=atfork_run_child) at register-atfork.c:134
#6 0x00007f0c986a672d in __libc_fork () at ../sysdeps/nptl/fork.c:137
#7 0x00007f0c98652824 in _IO_new_proc_open (fp=fp@entry=0x6110000c1100, command=command@entry=0x603000131380 "/usr/bin/chronyc tracking 2>&1", mode=<optimized out>,
mode@entry=0x4414e60 "r") at iopopen.c:122
#8 0x00007f0c98652ac8 in _IO_new_popen (command=0x603000131380 "/usr/bin/chronyc tracking 2>&1", mode=0x4414e60 "r") at iopopen.c:203
#9 0x0000000002e24af2 in bytebase::common::CommandRunner::Exec (command=...) at code/src/common/command_runner.cc:13
#18 0x0000000002d5aa2f in make_pcontext ()
#19 0x0000000000000000 in ?? () Looks similar to this issue: #945 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is needed so that the main coroutine that executes on a host's stack and therefore doesn't have the coroutine stack pointer filled in, actually got it filled. Otherwise asan doesn't know to what stack we switch, when switching back to main coroutine, and that results in: ==3966254==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x000000000000; bottom 0x7ffe3979b000; size: 0xffff8001c6865000 (-140729862696960) False positive error reports may follow For details see google/sanitizers#189 Which is fixed by this patch. Thanks to @ioquatix for the suggestion.
@ramosian-glider |
For coroutine, we should use `__sanitizer_start_switch_fiber` which similar to`VALGRIND_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 google/sanitizers#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. --- Co-authored-by: john <hondaxiao@tencent.com>
This is needed so that the main coroutine that executes on a host's stack and therefore doesn't have the coroutine stack pointer filled in, actually got it filled. Otherwise asan doesn't know to what stack we switch, when switching back to main coroutine, and that results in: ==3966254==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x000000000000; bottom 0x7ffe3979b000; size: 0xffff8001c6865000 (-140729862696960) False positive error reports may follow For details see google/sanitizers#189 Which is fixed by this patch. Thanks to @ioquatix for the suggestion.
I met this problem in Windows, and I found it useful to expand the stack size (i.e. Hope it help something. |
Originally reported on Google Code with ID 189
Reported by
konstantin.s.serebryany
on 2013-05-22 07:40:59The text was updated successfully, but these errors were encountered: