However, it only seems to work at -O0. At -O1 we get the following error when using fibers (with fake stacks):
AddressSanitizer: CHECK failed: asan_thread.cpp:371 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0) (tid=630766)
#0 0x7f8117537fca in CheckUnwind /usr/src/debug/gcc/libsanitizer/asan/asan_rtl.cpp:67
#1 0x7f811755b275 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_termination.cpp:86
#2 0x7f811753d4fe in __asan::AsanThread::GetStackFrameAccessByAddr(unsigned long, __asan::AsanThread::StackFrameAccess*) /usr/src/debug/gcc/libsanitizer/asan/asan_thread.cpp:371
#3 0x7f811749d4dd in __asan::GetStackAddressInformation(unsigned long, unsigned long, __asan::StackAddressDescription*) /usr/src/debug/gcc/libsanitizer/asan/asan_descriptions.cpp:202
#4 0x7f811749e87d in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) /usr/src/debug/gcc/libsanitizer/asan/asan_descriptions.cpp:455
#5 0x7f81174a0d95 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) /usr/src/debug/gcc/libsanitizer/asan/asan_errors.cpp:390
#6 0x7f81175370b6 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) /usr/src/debug/gcc/libsanitizer/asan/asan_report.cpp:477
#7 0x7f81174c83ed in __interceptor_sigaltstack /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:10168
#8 0x7f8117532ac4 in __asan::PlatformUnpoisonStacks() /usr/src/debug/gcc/libsanitizer/asan/asan_posix.cpp:44
#9 0x7f8117539d3d in __asan_handle_no_return /usr/src/debug/gcc/libsanitizer/asan/asan_rtl.cpp:606
#10 0x555df104556b in fiber_entry ../cont.c:767
Not sure if it's something we are doing wrong, but the fact it works with -O0 makes me think we are doing everything correctly and this is a compiler bug/issue.
I'll try to merge my branch into CRuby shortly, and then here is roughly speaking how to build a failing example:
> git checkout git@github.com:ruby/ruby.git
> cd ruby
> ./autogen.sh
> mkdir build && cd build
> ../configure cppflags="-fsanitize=address -fno-omit-frame-pointer" optflags=-O0 LDFLAGS="-fsanitize=address -fno-omit-frame-pointer"
> make
Copy the following into test.rb in the source root, and run in the build directory make runruby.
require_relative 'test/fiber/scheduler'
100.times do
$stderr.puts "."
thread = Thread.new do
scheduler = Scheduler.new
Fiber.set_scheduler scheduler
10.times do
Fiber.schedule do
sleep 0.1
end
end
end
thread.join
end
I'm trying to add ASAN to CRuby.
I think for the most part it's working.
However, it only seems to work at
-O0
. At-O1
we get the following error when using fibers (with fake stacks):Not sure if it's something we are doing wrong, but the fact it works with
-O0
makes me think we are doing everything correctly and this is a compiler bug/issue.I'll try to merge my branch into CRuby shortly, and then here is roughly speaking how to build a failing example:
Copy the following into
test.rb
in the source root, and run in the build directorymake runruby
.