Opened 9 years ago
Closed 9 years ago
#9180 closed Bugs (wontfix)
Valgrind reports usage of uninitialised values
Reported by: | Owned by: | olli | |
---|---|---|---|
Milestone: | To Be Determined | Component: | coroutine |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
When running the following example with Valgrind:
#include <iostream> #include <boost/coroutine/coroutine.hpp> typedef boost::coroutines::coroutine<int()> generator; void bar(generator::caller_type& yield) { yield(32); } void foo(generator::caller_type& yield) { generator nested_gen(bar); std::cout << nested_gen.get() << std::endl; yield(33); } int main() { generator gen(foo); std::cout << gen.get() << std::endl; return 0; };
I get the following trace (this is an extract, I give only the first error):
$ valgrind --max-stackframe=6516920 --track-origins=yes ./a.out
==10734== Memcheck, a memory error detector ==10734== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==10734== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==10734== Command: ./a.out ==10734== ==10734== Warning: client switching stacks? SP change: 0x7ff0001b8 --> 0x512af98 ==10734== to suppress, use: --max-stackframe=34257850912 or greater ==10734== Warning: client switching stacks? SP change: 0x512aca8 --> 0x5761f98 ==10734== to suppress, use: --max-stackframe=6517488 or greater ==10734== Use of uninitialised value of size 8 ==10734== at 0x4C0E727: jump_fcontext (in /home/ahamez/usr/boost1.54/lib/libboost_context.so.1.54.0) ==10734== by 0x40C6E9: boost::coroutines::detail::coroutine_object<int (), void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::detail::standard_stack_allocator, std::allocator<boost::coroutines::coroutine<int (), 0> >, boost::coroutines::coroutine<void (int), 1>, int, 0>::coroutine_object(void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::attributes const&, boost::coroutines::detail::standard_stack_allocator const&, std::allocator<boost::coroutines::detail::coroutine_object<int (), void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::detail::standard_stack_allocator, std::allocator<boost::coroutines::coroutine<int (), 0> >, boost::coroutines::coroutine<void (int), 1>, int, 0> > const&) (in /home/ahamez/a.out) ==10734== by 0x407F29: boost::coroutines::coroutine<int (), 0>::coroutine<void (*)(boost::coroutines::coroutine<void (int), 1>&)>(void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::attributes const&, boost::coroutines::detail::standard_stack_allocator const&, std::allocator<boost::coroutines::coroutine<int (), 0> > const&, boost::disable_if<boost::is_convertible<void (*&)(boost::coroutines::coroutine<void (int), 1>&), boost::rv<void (*)(boost::coroutines::coroutine<void (int), 1>&)>&>, boost::coroutines::coroutine<int (), 0>::dummy*>::type) (in /home/ahamez/a.out) ==10734== by 0x403DB9: foo(boost::coroutines::coroutine<void (int), 1>&) (in /home/ahamez/a.out) ==10734== by 0x410A1C: boost::coroutines::detail::coroutine_object<int (), void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::detail::standard_stack_allocator, std::allocator<boost::coroutines::coroutine<int (), 0> >, boost::coroutines::coroutine<void (int), 1>, int, 0>::run() (in /home/ahamez/a.out) ==10734== by 0x40EAC6: void boost::coroutines::detail::trampoline1<boost::coroutines::detail::coroutine_object<int (), void (*)(boost::coroutines::coroutine<void (int), 1>&), boost::coroutines::detail::standard_stack_allocator, std::allocator<boost::coroutines::coroutine<int (), 0> >, boost::coroutines::coroutine<void (int), 1>, int, 0> >(long) (in /home/ahamez/a.out) ==10734== by 0x4C0E6BD: make_fcontext (in /home/ahamez/usr/boost1.54/lib/libboost_context.so.1.54.0) ==10734== Uninitialised value was created by a stack allocation ==10734== at 0x4C0E723: jump_fcontext (in /home/ahamez/usr/boost1.54/lib/libboost_context.so.1.54.0)
Tested under MacOS X 10.8 with clang 3.3 and under Linux (CentOS 6) with gcc 4.8. I can't say if it's just Valgrind which can't cope with coroutines or if it's a real bug from Boost.Coroutine.
Note:
See TracTickets
for help on using tickets.
coroutines swap the stack-pointer (and some other registers) which might confuse valgrind. 'Warning: client switching stacks? SP change: 0x512aca8 -->'